1

I am trying to create a function which will generate lines using yield. But I got this error:

Parse error: syntax error, unexpected '$line' (T_VARIABLE)

$emails = file_get_contents("addresses.txt");
function yieldEmails($emails){
 $start_time = microtime(true);
 foreach ($emails as $i => $em):
   $line = array( "test@test.com", 12);
   yield $line;
 endforeach;
}

$indexes = yieldEmails($emails);

Can you explain what's wrong?

Johny Bony
  • 375
  • 2
  • 9

0 Answers0