3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = [0=>[id=>105, bla=>"sd"], 1=>[id=>300, bla=>"mvk"]]; $fixed = []; foreach ($arr as $a) { $fixed[$a["id"]] = $a; } unset($arr); var_dump($fixed);
Output for 7.2.0
Warning: Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP) in /in/15iEJ on line 3 Warning: Use of undefined constant bla - assumed 'bla' (this will throw an Error in a future version of PHP) in /in/15iEJ on line 3 Warning: Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP) in /in/15iEJ on line 3 Warning: Use of undefined constant bla - assumed 'bla' (this will throw an Error in a future version of PHP) in /in/15iEJ on line 3 array(2) { [105]=> array(2) { ["id"]=> int(105) ["bla"]=> string(2) "sd" } [300]=> array(2) { ["id"]=> int(300) ["bla"]=> string(3) "mvk" } }
Output for 5.4.12 - 7.1.10
Notice: Use of undefined constant id - assumed 'id' in /in/15iEJ on line 3 Notice: Use of undefined constant bla - assumed 'bla' in /in/15iEJ on line 3 Notice: Use of undefined constant id - assumed 'id' in /in/15iEJ on line 3 Notice: Use of undefined constant bla - assumed 'bla' in /in/15iEJ on line 3 array(2) { [105]=> array(2) { ["id"]=> int(105) ["bla"]=> string(2) "sd" } [300]=> array(2) { ["id"]=> int(300) ["bla"]=> string(3) "mvk" } }
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/15iEJ on line 3
Process exited with code 255.