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 13 14$column_key = new ColumnKeyClass(); 15$index_key = new IndexKeyClass(); 16 17 18// Array representing a possible record set returned from a database 19$records = array( 20 array( 21 'id' => 2135, 22 'first_name' => 'John', 23 'last_name' => 'XXX' 24 ), 25 array( 26 'id' => 3245, 27 'first_name' => 'Sally', 28 'last_name' => 'Smith' 29 ), 30); 31$firstNames = array_column($records, $column_key, $index_key); 32print_r($firstNames); 33var_dump($column_key); 34var_dump($index_key); 35 36?> 37--EXPECT-- 38Array 39( 40 [2135] => John 41 [3245] => Sally 42) 43object(ColumnKeyClass)#1 (0) { 44} 45object(IndexKeyClass)#2 (0) { 46} 47