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