-1

New to php. I'm having trouble determining the error in my code. I keep getting this error

Parse error: syntax error, unexpected 'preg_match' (T_STRING) in /Applications/MAMP/htdocs/blackiris/blackiris/syriaexhibition/syriaexhibition.php on line 16

header('content-type: text/plain');
$contents = file_get_contents('https://www.youtube.com/results?search_sort=video_date_uploaded&search_query=syria');
$contents = preg_replace('/\s(1,)/', ' ', $contents);

print $contents . "\n";
// if ($contents === false)
//  print 'False';
// print_r($contents);
$records = $preg_split('/<h3 class="yt/', $contents);

for ($ix = 1; $ix < count($records); $ix++)  (
$tmp = $records[$ix]

preg_match('/href="(.*?)"/', $tmp, $match_url);

print_r($match_url);

exit();
)
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

1 Answers1

1

You need a semicolon after $tmp = $records[$ix] and the ( and ) in the foreach should be { and }:

for ($ix = 1; $ix < count($records); $ix++)  {
  $tmp = $records[$ix];                   // ^ //
                   // ^ //
  preg_match('/href="(.*?)"/', $tmp, $match_url));

  print_r($match_url);

  exit();
}  // < //
DutGRIFF
  • 5,103
  • 1
  • 33
  • 42