3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array( array( 'firstname' => 'Bob', 'lastname' => 'Tomato' ), array( 'firstname' => 'Larry', 'lastname' => 'Cucumber' ) ); $keys = array_keys($arr[0]); // get all keys; var_dump(array_merge(array($arr), $keys)); $var = call_user_func_array("array_column", array_merge($arr, $keys)); print_r($var); ?>
Output for 5.5.24 - 7.1.0
array(3) { [0]=> array(2) { [0]=> array(2) { ["firstname"]=> string(3) "Bob" ["lastname"]=> string(6) "Tomato" } [1]=> array(2) { ["firstname"]=> string(5) "Larry" ["lastname"]=> string(8) "Cucumber" } } [1]=> string(9) "firstname" [2]=> string(8) "lastname" } Warning: array_column() expects at most 3 parameters, 4 given in /in/lJS3S on line 16
Output for 5.3.0 - 5.4.45
array(3) { [0]=> array(2) { [0]=> array(2) { ["firstname"]=> string(3) "Bob" ["lastname"]=> string(6) "Tomato" } [1]=> array(2) { ["firstname"]=> string(5) "Larry" ["lastname"]=> string(8) "Cucumber" } } [1]=> string(9) "firstname" [2]=> string(8) "lastname" } Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'array_column' not found or invalid function name in /in/lJS3S on line 16
Output for 5.0.0 - 5.2.17
array(3) { [0]=> array(2) { [0]=> array(2) { ["firstname"]=> string(3) "Bob" ["lastname"]=> string(6) "Tomato" } [1]=> array(2) { ["firstname"]=> string(5) "Larry" ["lastname"]=> string(8) "Cucumber" } } [1]=> string(9) "firstname" [2]=> string(8) "lastname" } Warning: call_user_func_array(): First argument is expected to be a valid callback, 'array_column' was given in /in/lJS3S on line 16
Output for 4.3.2 - 4.4.9
array(3) { [0]=> array(2) { [0]=> array(2) { ["firstname"]=> string(3) "Bob" ["lastname"]=> string(6) "Tomato" } [1]=> array(2) { ["firstname"]=> string(5) "Larry" ["lastname"]=> string(8) "Cucumber" } } [1]=> string(9) "firstname" [2]=> string(8) "lastname" } Warning: call_user_func_array(): First argumented is expected to be a valid callback, 'array_column' was given in /in/lJS3S on line 16
Output for 4.3.0 - 4.3.1
array(3) { [0]=> array(2) { [0]=> array(2) { ["firstname"]=> string(3) "Bob" ["lastname"]=> string(6) "Tomato" } [1]=> array(2) { ["firstname"]=> string(5) "Larry" ["lastname"]=> string(8) "Cucumber" } } [1]=> string(9) "firstname" [2]=> string(8) "lastname" } Warning: call_user_func_array() [http://www.php.net/function.call-user-func-array]: First argumented is expected to be a valid callback, 'array_column' was given in /in/lJS3S on line 16