3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $eggCount = 3; for($i = 1; $i <= $eggCount; $i++) { create("eggs", array($i => array("ID" => $i))); } function create($arrName, Array $arrKeys) { $lName = strtolower($arrName); $$lName = array(); foreach($arrKeys as $key => $value) { $$lName[$key] = $value; } for($i = 1; $i <= $GLOBALS['eggCount']; $i++) { // echo "Egg $i's ID: " . $eggs[$i]['ID']; } print_r($$lName); }
Output for 7.0.0 - 7.1.0
Array ( [1] => Array ( [ID] => 1 ) ) Array ( [2] => Array ( [ID] => 2 ) ) Array ( [3] => Array ( [ID] => 3 ) )
Output for 5.1.0 - 5.6.28, hhvm-3.10.0 - 3.12.0
Array ( ) Array ( ) Array ( )
Output for 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in <b>/in/ReNZl</b> on line <b>9</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in <b>/in/ReNZl</b> on line <b>9</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in <b>/in/ReNZl</b> on line <b>9</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error, expecting `'&'' or `T_VARIABLE' or `T_CONST' in <b>/in/ReNZl</b> on line <b>9</b><br />
Process exited with code 255.