3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // result from db $recordset = [ [ 'id' => 1337, 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], [ 'id' => 1347, 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], ]; // this I want $recordset = [ 1337 => [ 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], 1347 => [ 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], ]; $result = array_diff_key(array('id'=>1), ...$record); var_dump($result);
Output for 5.6.0 - 7.1.0
Notice: Undefined variable: record in /in/BHJFQ on line 33 Warning: Only arrays and Traversables can be unpacked in /in/BHJFQ on line 33 Warning: array_diff_key(): at least 2 parameters are required, 1 given in /in/BHJFQ on line 33 NULL
Output for 5.4.0 - 5.5.38
Parse error: syntax error, unexpected '.' in /in/BHJFQ on line 33
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/BHJFQ on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/BHJFQ on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/BHJFQ on line 4
Process exited with code 255.