Case1:";
$title="A.I. Rising (2018)";
print "original title= ".$title."
";
$title2 = explode(" ", $title); // parse movie title from review string, split it into array based " "
$result = preg_grep("/\(\d{4}\)/", $title2); // searches for (YEAR) using regular expression
var_dump($result); //see index in array
foreach($result as $year_index => $year_value) {
$year = substr($year_value, 1, 4); //set the last (YEAR) to $year
}
$index = count($result); // gets the index of the single returned value
$title3 = explode("(", $title); // parse movie title from review string
var_dump($title3); //see index
if (count($result) > 0)
$title = trim($title3[0]);
echo "
fixed title= ".$title."
";
//echo $title."
";
$url_omdbapi = 'http://www.omdbapi.com/?t=';
$url = $url_omdbapi.$title.'&y='.$year.'&plot=short&r=json&apikey=1cdf8d38';
echo "url=".$url."";
echo "
";
?>