1--TEST-- 2Test array_column() function: variant functionality 3--FILE-- 4<?php 5/* Array from Bug Request #64493 test script */ 6$rows = array( 7 456 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'), 8 457 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'), 9); 10 11echo "-- pass null as second parameter to get back all columns indexed by third parameter --\n"; 12var_dump(array_column($rows, null, 'id')); 13 14echo "-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns --\n"; 15var_dump(array_column($rows, null, 'foo')); 16 17echo "-- pass null as second parameter and no third param to get back array_values(input) --\n"; 18var_dump(array_column($rows, null)); 19 20echo "Done\n"; 21?> 22--EXPECT-- 23-- pass null as second parameter to get back all columns indexed by third parameter -- 24array(2) { 25 [3]=> 26 array(3) { 27 ["id"]=> 28 string(1) "3" 29 ["title"]=> 30 string(3) "Foo" 31 ["date"]=> 32 string(10) "2013-03-25" 33 } 34 [5]=> 35 array(3) { 36 ["id"]=> 37 string(1) "5" 38 ["title"]=> 39 string(3) "Bar" 40 ["date"]=> 41 string(10) "2012-05-20" 42 } 43} 44-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns -- 45array(2) { 46 [0]=> 47 array(3) { 48 ["id"]=> 49 string(1) "3" 50 ["title"]=> 51 string(3) "Foo" 52 ["date"]=> 53 string(10) "2013-03-25" 54 } 55 [1]=> 56 array(3) { 57 ["id"]=> 58 string(1) "5" 59 ["title"]=> 60 string(3) "Bar" 61 ["date"]=> 62 string(10) "2012-05-20" 63 } 64} 65-- pass null as second parameter and no third param to get back array_values(input) -- 66array(2) { 67 [0]=> 68 array(3) { 69 ["id"]=> 70 string(1) "3" 71 ["title"]=> 72 string(3) "Foo" 73 ["date"]=> 74 string(10) "2013-03-25" 75 } 76 [1]=> 77 array(3) { 78 ["id"]=> 79 string(1) "5" 80 ["title"]=> 81 string(3) "Bar" 82 ["date"]=> 83 string(10) "2012-05-20" 84 } 85} 86Done 87