3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit
object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } object(ValueClass)#3 (0) { } object(ValueClass)#3 (0) { } Fatal error: Uncaught TypeError: Illegal offset type in /in/1uMqh:38 Stack trace: #0 /in/1uMqh(38): array_column(Array, 'first_name', 'id') #1 {main} thrown in /in/1uMqh on line 38
Process exited with code 255.
Output for rfc.property-hooks
object(ColumnKeyClass)#1 (0) { } object(IndexKeyClass)#2 (0) { } object(ValueClass)#3 (0) { } object(ValueClass)#3 (0) { } Fatal error: Uncaught TypeError: Cannot access offset of type object on array in /in/1uMqh:38 Stack trace: #0 /in/1uMqh(38): array_column(Array, 'first_name', 'id') #1 {main} thrown in /in/1uMqh on line 38
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.45 ms | 401 KiB | 8 Q