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'; } } class ValueClass { function __toString() { return '2135'; } } $column_key = new ColumnKeyClass(); $index_key = new IndexKeyClass(); $value = new ValueClass(); // Array representing a possible record set returned from a database $records = array( array( 'id' => $value, 'first_name' => 'John', 'last_name' => 'XXX' ), array( 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith' ), ); var_dump($column_key); var_dump($index_key); var_dump($value); var_dump($records[0]['id']); $firstNames = array_column($records, $column_key, $index_key); print_r($firstNames); var_dump($column_key); var_dump($index_key); var_dump($value); var_dump($records[0]['id']);
Output for hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } object(ValueClass)#3 (0) { } object(ValueClass)#3 (0) { } Array ( [2135] => John [3245] => Sally ) object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } object(ValueClass)#3 (0) { } object(ValueClass)#3 (0) { }
Output for 5.5.0 - 5.6.28
object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } object(ValueClass)#3 (0) { } object(ValueClass)#3 (0) { } Array ( [2135] => John [3245] => Sally ) object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } object(ValueClass)#3 (0) { } string(4) "2135"
Output for 5.0.0 - 5.4.45
object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } object(ValueClass)#3 (0) { } object(ValueClass)#3 (0) { } Fatal error: Call to undefined function array_column() in /in/1uMqh on line 38
Process exited with code 255.
Output for 4.4.5 - 4.4.9
object(columnkeyclass)(0) { } object(indexkeyclass)(0) { } object(valueclass)(0) { } object(valueclass)(0) { } Fatal error: Call to undefined function: array_column() in /in/1uMqh on line 38
Process exited with code 255.
Output for 4.3.2 - 4.4.4
object(columnkeyclass)(0) { } object(indexkeyclass)(0) { } object(valueclass)(0) { } object(valueclass)(0) { } Fatal error: Call to undefined function: array_column() in /in/1uMqh on line 38
Process exited with code 255.
Output for 4.3.0 - 4.3.1
object(columnkeyclass)(0) { } object(indexkeyclass)(0) { } object(valueclass)(0) { } object(valueclass)(0) { } Fatal error: Call to undefined function: array_column() in /in/1uMqh on line 38