1--TEST-- 2Test array_keys() function (variation - 1) 3--FILE-- 4<?php 5 6echo "\n*** Testing array_keys() on various arrays ***"; 7$arrays = array( 8 array(), 9 array(0), 10 array( array() ), 11 array("Hello" => "World"), 12 array("" => ""), 13 array(1,2,3, "d" => array(4,6, "d")), 14 array("a" => 1, "b" => 2, "c" =>3, "d" => array()), 15 array(0 => 0, 1 => 1, 2 => 2, 3 => 3), 16 array(0.001=>3.000, 1.002=>2, 1.999=>3, "a"=>3, 3=>5, "5"=>3.000), 17 array(TRUE => TRUE, FALSE => FALSE, NULL => NULL, "\x000", "\000"), 18 array("a" => "abcd", "a" => "", "ab" => -6, "cd" => -0.5 ), 19 array(0 => array(), 1=> array(0), 2 => array(1), ""=> array(),""=>"" ) 20); 21 22$i = 0; 23/* loop through to test array_keys() with different arrays */ 24foreach ($arrays as $array) { 25 echo "\n-- Iteration $i --\n"; 26 var_dump(array_keys($array)); 27 $i++; 28} 29 30echo "Done\n"; 31?> 32--EXPECT-- 33*** Testing array_keys() on various arrays *** 34-- Iteration 0 -- 35array(0) { 36} 37 38-- Iteration 1 -- 39array(1) { 40 [0]=> 41 int(0) 42} 43 44-- Iteration 2 -- 45array(1) { 46 [0]=> 47 int(0) 48} 49 50-- Iteration 3 -- 51array(1) { 52 [0]=> 53 string(5) "Hello" 54} 55 56-- Iteration 4 -- 57array(1) { 58 [0]=> 59 string(0) "" 60} 61 62-- Iteration 5 -- 63array(4) { 64 [0]=> 65 int(0) 66 [1]=> 67 int(1) 68 [2]=> 69 int(2) 70 [3]=> 71 string(1) "d" 72} 73 74-- Iteration 6 -- 75array(4) { 76 [0]=> 77 string(1) "a" 78 [1]=> 79 string(1) "b" 80 [2]=> 81 string(1) "c" 82 [3]=> 83 string(1) "d" 84} 85 86-- Iteration 7 -- 87array(4) { 88 [0]=> 89 int(0) 90 [1]=> 91 int(1) 92 [2]=> 93 int(2) 94 [3]=> 95 int(3) 96} 97 98-- Iteration 8 -- 99array(5) { 100 [0]=> 101 int(0) 102 [1]=> 103 int(1) 104 [2]=> 105 string(1) "a" 106 [3]=> 107 int(3) 108 [4]=> 109 int(5) 110} 111 112-- Iteration 9 -- 113array(5) { 114 [0]=> 115 int(1) 116 [1]=> 117 int(0) 118 [2]=> 119 string(0) "" 120 [3]=> 121 int(2) 122 [4]=> 123 int(3) 124} 125 126-- Iteration 10 -- 127array(3) { 128 [0]=> 129 string(1) "a" 130 [1]=> 131 string(2) "ab" 132 [2]=> 133 string(2) "cd" 134} 135 136-- Iteration 11 -- 137array(4) { 138 [0]=> 139 int(0) 140 [1]=> 141 int(1) 142 [2]=> 143 int(2) 144 [3]=> 145 string(0) "" 146} 147Done 148