As in the php manual yield can use part of a expression. $data = (yield $value); But it doesn’t assigned anything to $myval. Am i doing something wrong here? How we can use it in a expression?
function test_yield(){
for ($i=0; $i <10; $i++) {
$myval = (yield $i);
echo " \ ".$myval." / <br />";
}
}
foreach (test_yield() as $value) {
echo $value;
}