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
95
96Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
97
98Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
99array(4) {
100  [0]=>
101  array(4) {
102    [0]=>
103    int(1)
104    [1]=>
105    int(2)
106    [2]=>
107    string(5) "hello"
108    [3]=>
109    string(5) "world"
110  }
111  [1]=>
112  array(4) {
113    [0]=>
114    int(1)
115    [1]=>
116    int(2)
117    [2]=>
118    int(3)
119    [3]=>
120    int(4)
121  }
122  [2]=>
123  array(3) {
124    [1]=>
125    string(3) "one"
126    [2]=>
127    string(3) "two"
128    [3]=>
129    string(5) "three"
130  }
131  [3]=>
132  array(3) {
133    ["ten"]=>
134    int(10)
135    ["twenty"]=>
136    float(20)
137    ["thirty"]=>
138    int(30)
139  }
140}
141- With more arguments -
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
186
187Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
188
189Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
190
191Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
192
193Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
194
195Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
196
197Notice: Array to string conversion in %sarray_intersect_variation9.php on line %d
198array(4) {
199  [0]=>
200  array(4) {
201    [0]=>
202    int(1)
203    [1]=>
204    int(2)
205    [2]=>
206    string(5) "hello"
207    [3]=>
208    string(5) "world"
209  }
210  [1]=>
211  array(4) {
212    [0]=>
213    int(1)
214    [1]=>
215    int(2)
216    [2]=>
217    int(3)
218    [3]=>
219    int(4)
220  }
221  [2]=>
222  array(3) {
223    [1]=>
224    string(3) "one"
225    [2]=>
226    string(3) "two"
227    [3]=>
228    string(5) "three"
229  }
230  [3]=>
231  array(3) {
232    ["ten"]=>
233    int(10)
234    ["twenty"]=>
235    float(20)
236    ["thirty"]=>
237    int(30)
238  }
239}
240-- Passing the sub-array to $arr1 and $arr2 --
241- With default arguments -
242array(2) {
243  [0]=>
244  int(1)
245  [1]=>
246  int(2)
247}
248- With more arguments -
249array(2) {
250  [0]=>
251  int(1)
252  [1]=>
253  int(2)
254}
255Done
256