3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [ ['a'=>'bla'], ['b'=>'test'], ['a'=>'foo'], ['c'=>'bar'] ]; $b = []; foreach ($a as $v) { $k = array_key_first($v); $b[$k][] = $v[$k]; } var_dump($b);
Output for 7.3.0 - 7.3.1
array(3) { ["a"]=> array(2) { [0]=> string(3) "bla" [1]=> string(3) "foo" } ["b"]=> array(1) { [0]=> string(4) "test" } ["c"]=> array(1) { [0]=> string(3) "bar" } }
Output for 7.1.25 - 7.2.13
Fatal error: Uncaught Error: Call to undefined function array_key_first() in /in/Eo1f9:10 Stack trace: #0 {main} thrown in /in/Eo1f9 on line 10
Process exited with code 255.