3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ColumnKeyClass { function __toString() { return 'first_name'; } } class IndexKeyClass { function __toString() { return 'id'; } } $column_key = new ColumnKeyClass(); $index_key = new IndexKeyClass(); $records = array( array( 'id' => 2135, 'first_name' => 'John', 'last_name' => 'XXX' ), array( 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith' )); var_dump($column_key); var_dump($index_key); $firstNames = array_column($records, $column_key, $index_key); print_r($firstNames); var_dump($column_key); var_dump($index_key);
Output for 5.5.24 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } Array ( [2135] => John [3245] => Sally ) object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { }
Output for 5.0.0 - 5.4.45
object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } Fatal error: Call to undefined function array_column() in /in/lQqh2 on line 20
Process exited with code 255.
Output for 4.4.5 - 4.4.9
object(columnkeyclass)(0) { } object(indexkeyclass)(0) { } Fatal error: Call to undefined function: array_column() in /in/lQqh2 on line 20
Process exited with code 255.
Output for 4.3.2 - 4.4.4
object(columnkeyclass)(0) { } object(indexkeyclass)(0) { } Fatal error: Call to undefined function: array_column() in /in/lQqh2 on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1
object(columnkeyclass)(0) { } object(indexkeyclass)(0) { } Fatal error: Call to undefined function: array_column() in /in/lQqh2 on line 20