3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { public function __construct() { $item = $this->itemResolver(); foreach(iterator_to_array($item,true) as $number => $value){ var_dump($value); } } public function itemResolver(): \Generator { // $stmt = mysqli_query($db_connect, "select pk_i_id from oc_t_item_resource ORDER by pk_i_id desc"); // $records = mysqli_fetch_all($stmt); $records = [ 0 => [0 => '4031'], 1 => [0 => '4030'], 2 => [0 => '4029'] ]; foreach($records as $record => $value){ yield $value; } } } var_dump(new Test());
based on fqQuX
Output for 7.0.28 - 7.3.0rc3
array(1) { [0]=> string(4) "4031" } array(1) { [0]=> string(4) "4030" } array(1) { [0]=> string(4) "4029" } object(Test)#1 (0) { }
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/MoHjI on line 15
Process exited with code 255.