1--TEST-- 2Test array_intersect() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments(Bug#43109) 3--FILE-- 4<?php 5/* 6* Testing the behavior of array_intersect() by passing 2-D arrays 7* to both $arr1 and $arr2 argument. 8* Optional argument takes the same value as that of $arr1 9*/ 10 11echo "*** Testing array_intersect() : passing two dimensional array to both \$arr1 and \$arr2 arguments ***\n"; 12 13// two dimensional arrays for $arr1 and $arr2 argument 14$arr1 = array ( 15 16 // arrays with default keys 17 array(1, 2, "hello", 'world'), 18 array(1, 2, 3, 4), 19 20 // arrays with explicit keys 21 array(1 => "one", 2 => "two", 3 => "three"), 22 array("ten" => 10, "twenty" => 20.00, "thirty" => 30) 23); 24 25$arr2 = array ( 26 array(1, 2, 3, 4), 27 array(1 => "one", 2 => "two", 3 => "three") 28); 29 30/* Passing the entire array as argument to $arr1 and $arr2 */ 31// Calling array_intersect() with default arguments 32echo "-- Passing the entire 2-D array to \$arr1 and \$arr2 --\n"; 33echo "- With default arguments -\n"; 34var_dump( array_intersect($arr1, $arr2) ); 35 36// Calling array_intersect() with more arguments 37// additional argument passed is the same as $arr1 38echo "- With more arguments -\n"; 39var_dump( array_intersect($arr1, $arr2, $arr1) ); 40 41/* Passing the sub-array as argument to $arr1 and $arr2 */ 42// Calling array_intersect() with default arguments 43echo "-- Passing the sub-array to \$arr1 and \$arr2 --\n"; 44echo "- With default arguments -\n"; 45var_dump( array_intersect($arr1[0], $arr2[0]) ); 46 47// Calling array_intersect() with more arguments 48// additional argument passed is the same as $arr1 49echo "- With more arguments -\n"; 50var_dump( array_intersect($arr1[0], $arr2[0], $arr1[0]) ); 51 52echo "Done"; 53?> 54--EXPECTF-- 55*** Testing array_intersect() : passing two dimensional array to both $arr1 and $arr2 arguments *** 56-- Passing the entire 2-D array to $arr1 and $arr2 -- 57- With default arguments - 58 59Warning: Array to string conversion in %s on line %d 60 61Warning: Array to string conversion in %s on line %d 62 63Warning: Array to string conversion in %s on line %d 64 65Warning: Array to string conversion in %s on line %d 66 67Warning: Array to string conversion in %s on line %d 68 69Warning: Array to string conversion in %s on line %d 70 71Warning: Array to string conversion in %s on line %d 72 73Warning: Array to string conversion in %s on line %d 74 75Warning: Array to string conversion in %s on line %d 76 77Warning: Array to string conversion in %s on line %d 78 79Warning: Array to string conversion in %s on line %d 80 81Warning: Array to string conversion in %s on line %d 82 83Warning: Array to string conversion in %s on line %d 84 85Warning: Array to string conversion in %s on line %d 86 87Warning: Array to string conversion in %s on line %d 88 89Warning: Array to string conversion in %s on line %d 90array(4) { 91 [0]=> 92 array(4) { 93 [0]=> 94 int(1) 95 [1]=> 96 int(2) 97 [2]=> 98 string(5) "hello" 99 [3]=> 100 string(5) "world" 101 } 102 [1]=> 103 array(4) { 104 [0]=> 105 int(1) 106 [1]=> 107 int(2) 108 [2]=> 109 int(3) 110 [3]=> 111 int(4) 112 } 113 [2]=> 114 array(3) { 115 [1]=> 116 string(3) "one" 117 [2]=> 118 string(3) "two" 119 [3]=> 120 string(5) "three" 121 } 122 [3]=> 123 array(3) { 124 ["ten"]=> 125 int(10) 126 ["twenty"]=> 127 float(20) 128 ["thirty"]=> 129 int(30) 130 } 131} 132- With more arguments - 133 134Warning: Array to string conversion in %s on line %d 135 136Warning: Array to string conversion in %s on line %d 137 138Warning: Array to string conversion in %s on line %d 139 140Warning: Array to string conversion in %s on line %d 141 142Warning: Array to string conversion in %s on line %d 143 144Warning: Array to string conversion in %s on line %d 145 146Warning: Array to string conversion in %s on line %d 147 148Warning: Array to string conversion in %s on line %d 149 150Warning: Array to string conversion in %s on line %d 151 152Warning: Array to string conversion in %s on line %d 153 154Warning: Array to string conversion in %s on line %d 155 156Warning: Array to string conversion in %s on line %d 157 158Warning: Array to string conversion in %s on line %d 159 160Warning: Array to string conversion in %s on line %d 161 162Warning: Array to string conversion in %s on line %d 163 164Warning: Array to string conversion in %s on line %d 165 166Warning: Array to string conversion in %s on line %d 167 168Warning: Array to string conversion in %s on line %d 169 170Warning: Array to string conversion in %s on line %d 171 172Warning: Array to string conversion in %s on line %d 173 174Warning: Array to string conversion in %s on line %d 175 176Warning: Array to string conversion in %s on line %d 177 178Warning: Array to string conversion in %s on line %d 179 180Warning: Array to string conversion in %s on line %d 181array(4) { 182 [0]=> 183 array(4) { 184 [0]=> 185 int(1) 186 [1]=> 187 int(2) 188 [2]=> 189 string(5) "hello" 190 [3]=> 191 string(5) "world" 192 } 193 [1]=> 194 array(4) { 195 [0]=> 196 int(1) 197 [1]=> 198 int(2) 199 [2]=> 200 int(3) 201 [3]=> 202 int(4) 203 } 204 [2]=> 205 array(3) { 206 [1]=> 207 string(3) "one" 208 [2]=> 209 string(3) "two" 210 [3]=> 211 string(5) "three" 212 } 213 [3]=> 214 array(3) { 215 ["ten"]=> 216 int(10) 217 ["twenty"]=> 218 float(20) 219 ["thirty"]=> 220 int(30) 221 } 222} 223-- Passing the sub-array to $arr1 and $arr2 -- 224- With default arguments - 225array(2) { 226 [0]=> 227 int(1) 228 [1]=> 229 int(2) 230} 231- With more arguments - 232array(2) { 233 [0]=> 234 int(1) 235 [1]=> 236 int(2) 237} 238Done 239