1--TEST--
2Test array_intersect_assoc() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments
3--FILE--
4<?php
5/*
6* Testing the behavior of array_intersect_assoc() 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_assoc() : 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_assoc() with default arguments
32echo "-- Passing the entire 2-D array to \$arr1 and \$arr2 --\n";
33echo "- With default arguments -\n";
34var_dump( array_intersect_assoc($arr1, $arr2) );
35
36// Calling array_intersect_assoc() with more arguments
37// additional argument passed is the same as $arr1
38echo "- With more arguments -\n";
39var_dump( array_intersect_assoc($arr1, $arr2, $arr1) );
40
41/* Passing the sub-array as argument to $arr1 and $arr2 */
42// Calling array_intersect_assoc() with default arguments
43echo "-- Passing the sub-array to \$arr1 and \$arr2 --\n";
44echo "- With default arguments -\n";
45var_dump( array_intersect_assoc($arr1[0], $arr2[0]) );
46
47// Calling array_intersect_assoc() with more arguments
48// additional argument passed is the same as $arr1
49echo "- With more arguments -\n";
50var_dump( array_intersect_assoc($arr1[0], $arr2[0], $arr1[0]) );
51
52echo "Done";
53?>
54--EXPECTF--
55*** Testing array_intersect_assoc() : 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
66array(2) {
67  [0]=>
68  array(4) {
69    [0]=>
70    int(1)
71    [1]=>
72    int(2)
73    [2]=>
74    string(5) "hello"
75    [3]=>
76    string(5) "world"
77  }
78  [1]=>
79  array(4) {
80    [0]=>
81    int(1)
82    [1]=>
83    int(2)
84    [2]=>
85    int(3)
86    [3]=>
87    int(4)
88  }
89}
90- With more arguments -
91
92Warning: Array to string conversion in %s on line %d
93
94Warning: Array to string conversion in %s on line %d
95
96Warning: Array to string conversion in %s on line %d
97
98Warning: Array to string conversion in %s on line %d
99
100Warning: Array to string conversion in %s on line %d
101
102Warning: Array to string conversion in %s on line %d
103
104Warning: Array to string conversion in %s on line %d
105
106Warning: Array to string conversion in %s on line %d
107array(2) {
108  [0]=>
109  array(4) {
110    [0]=>
111    int(1)
112    [1]=>
113    int(2)
114    [2]=>
115    string(5) "hello"
116    [3]=>
117    string(5) "world"
118  }
119  [1]=>
120  array(4) {
121    [0]=>
122    int(1)
123    [1]=>
124    int(2)
125    [2]=>
126    int(3)
127    [3]=>
128    int(4)
129  }
130}
131-- Passing the sub-array to $arr1 and $arr2 --
132- With default arguments -
133array(2) {
134  [0]=>
135  int(1)
136  [1]=>
137  int(2)
138}
139- With more arguments -
140array(2) {
141  [0]=>
142  int(1)
143  [1]=>
144  int(2)
145}
146Done
147