3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Examples 1 & 2 from http://nl3.php.net/array_column $records = array( 4 => array( 'id' => 2135, 'first_name' => 'John', 'last_name' => 'Doe', ), 8 => array( 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith', ), 2 => array( 'id' => 5342, 'first_name' => 'Jane', 'last_name' => 'Jones', ), '00013411' => array( 'id' => 5623, 'first_name' => 'Peter', 'last_name' => 'Doe', ) ); // Example 1: original indexes are lost =( print_r(array_column($records, 'first_name')); // Example 2: new indexes are 'id' column print_r(array_column($records, 'last_name', 'id')); // Example 3: full objects by 'last_name' print_r(array_column($records, null, 'last_name'));
Output for 5.5.24 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [0] => John [1] => Sally [2] => Jane [3] => Peter ) Array ( [2135] => Doe [3245] => Smith [5342] => Jones [5623] => Doe ) Array ( [Doe] => Array ( [id] => 5623 [first_name] => Peter [last_name] => Doe ) [Smith] => Array ( [id] => 3245 [first_name] => Sally [last_name] => Smith ) [Jones] => Array ( [id] => 5342 [first_name] => Jane [last_name] => Jones ) )
Output for 5.0.0 - 5.4.45
Fatal error: Call to undefined function array_column() in /in/9kpKa on line 29
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: array_column() in /in/9kpKa on line 29
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: array_column() in /in/9kpKa on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: array_column() in /in/9kpKa on line 29