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--EXPECTF-- 22-- pass null as second parameter to get back all columns indexed by third parameter -- 23array(2) { 24 [3]=> 25 array(3) { 26 ["id"]=> 27 string(1) "3" 28 ["title"]=> 29 string(3) "Foo" 30 ["date"]=> 31 string(10) "2013-03-25" 32 } 33 [5]=> 34 array(3) { 35 ["id"]=> 36 string(1) "5" 37 ["title"]=> 38 string(3) "Bar" 39 ["date"]=> 40 string(10) "2012-05-20" 41 } 42} 43-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns -- 44array(2) { 45 [0]=> 46 array(3) { 47 ["id"]=> 48 string(1) "3" 49 ["title"]=> 50 string(3) "Foo" 51 ["date"]=> 52 string(10) "2013-03-25" 53 } 54 [1]=> 55 array(3) { 56 ["id"]=> 57 string(1) "5" 58 ["title"]=> 59 string(3) "Bar" 60 ["date"]=> 61 string(10) "2012-05-20" 62 } 63} 64-- pass null as second parameter and no third param to get back array_values(input) -- 65array(2) { 66 [0]=> 67 array(3) { 68 ["id"]=> 69 string(1) "3" 70 ["title"]=> 71 string(3) "Foo" 72 ["date"]=> 73 string(10) "2013-03-25" 74 } 75 [1]=> 76 array(3) { 77 ["id"]=> 78 string(1) "5" 79 ["title"]=> 80 string(3) "Bar" 81 ["date"]=> 82 string(10) "2012-05-20" 83 } 84} 85Done 86