1--TEST-- 2Test array_column() function: basic functionality 3--FILE-- 4<?php 5class ColumnKeyClass { 6 function __toString() { return 'first_name'; } 7} 8 9class IndexKeyClass { 10 function __toString() { return 'id'; } 11} 12 13class ValueClass { 14 function __toString() { return '2135'; } 15} 16 17 18$column_key = new ColumnKeyClass(); 19$index_key = new IndexKeyClass(); 20$value = new ValueClass(); 21 22 23// Array representing a possible record set returned from a database 24$records = array( 25 array( 26 'id' => $value, 27 'first_name' => 'John', 28 'last_name' => 'XXX' 29 ), 30 array( 31 'id' => 3245, 32 'first_name' => 'Sally', 33 'last_name' => 'Smith' 34 ), 35); 36$firstNames = array_column($records, $column_key, $index_key); 37print_r($firstNames); 38var_dump($column_key); 39var_dump($index_key); 40var_dump($value); 41--EXPECTF-- 42Array 43( 44 [2135] => John 45 [3245] => Sally 46) 47object(ColumnKeyClass)#%d (0) { 48} 49object(IndexKeyClass)#%d (0) { 50} 51object(ValueClass)#%d (0) { 52} 53