<?php
function getNumsOdd(array $nums)
{
foreach($nums as $key => $num) {
if ($num % 2) {
yield $key => $num;
}
}
}
$i = 0;
while($num = getNumsOdd([1,3,4,5,6])) {
var_dump($num->current());
if (++$i = 10){
break;
}
}
/*foreach(getNumsOdd([1,3,4,5,6]) as $key => $num) {
echo $key . '=>' . $num.PHP_EOL;
}*/
- Output for 5.4.0 - 5.4.30
- Parse error: syntax error, unexpected '$key' (T_VARIABLE) in /in/iBGUW on line 6
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected T_VARIABLE in /in/iBGUW on line 6
Process exited with code 255.
preferences:
194.9 ms | 1394 KiB | 67 Q