1--TEST--
2Test array_diff_assoc() function : usage variations - compare multidimensional arrays
3--FILE--
4<?php
5/*
6 * Test how array_diff_assoc behaves when comparing
7 * multi-dimensional arrays
8 */
9
10echo "*** Testing array_diff_assoc() : usage variations ***\n";
11
12$array1 = array('sub_array1' => array (1, 2, 3),
13                'sub_array2' => array ('a', 'b', 'c'));
14$array2 = array('sub_arraya' => array (1, 3, 5),
15                'sub_arrayb' => array ('a', 'z', 'y'));
16
17echo "-- Compare two 2-D arrays --\n";
18var_dump(array_diff_assoc($array1, $array2));
19var_dump(array_diff_assoc($array2, $array1));
20
21echo "\n-- Compare subarrays from two 2-D arrays --\n";
22var_dump(array_diff_assoc($array1['sub_array1'], $array2['sub_arraya']));
23var_dump(array_diff_assoc($array2['sub_arraya'], $array1['sub_array1']));
24var_dump(array_diff_assoc($array1['sub_array2'], $array2['sub_arrayb']));
25var_dump(array_diff_assoc($array2['sub_arrayb'], $array1['sub_array1']));
26
27echo "\n-- Compare a subarray from one 2-D array and one 2-D array --\n";
28var_dump(array_diff_assoc($array1['sub_array1'], $array2));
29var_dump(array_diff_assoc($array1, $array2['sub_arraya']));
30
31echo "Done";
32?>
33--EXPECT--
34*** Testing array_diff_assoc() : usage variations ***
35-- Compare two 2-D arrays --
36array(2) {
37  ["sub_array1"]=>
38  array(3) {
39    [0]=>
40    int(1)
41    [1]=>
42    int(2)
43    [2]=>
44    int(3)
45  }
46  ["sub_array2"]=>
47  array(3) {
48    [0]=>
49    string(1) "a"
50    [1]=>
51    string(1) "b"
52    [2]=>
53    string(1) "c"
54  }
55}
56array(2) {
57  ["sub_arraya"]=>
58  array(3) {
59    [0]=>
60    int(1)
61    [1]=>
62    int(3)
63    [2]=>
64    int(5)
65  }
66  ["sub_arrayb"]=>
67  array(3) {
68    [0]=>
69    string(1) "a"
70    [1]=>
71    string(1) "z"
72    [2]=>
73    string(1) "y"
74  }
75}
76
77-- Compare subarrays from two 2-D arrays --
78array(2) {
79  [1]=>
80  int(2)
81  [2]=>
82  int(3)
83}
84array(2) {
85  [1]=>
86  int(3)
87  [2]=>
88  int(5)
89}
90array(2) {
91  [1]=>
92  string(1) "b"
93  [2]=>
94  string(1) "c"
95}
96array(3) {
97  [0]=>
98  string(1) "a"
99  [1]=>
100  string(1) "z"
101  [2]=>
102  string(1) "y"
103}
104
105-- Compare a subarray from one 2-D array and one 2-D array --
106array(3) {
107  [0]=>
108  int(1)
109  [1]=>
110  int(2)
111  [2]=>
112  int(3)
113}
114array(2) {
115  ["sub_array1"]=>
116  array(3) {
117    [0]=>
118    int(1)
119    [1]=>
120    int(2)
121    [2]=>
122    int(3)
123  }
124  ["sub_array2"]=>
125  array(3) {
126    [0]=>
127    string(1) "a"
128    [1]=>
129    string(1) "b"
130    [2]=>
131    string(1) "c"
132  }
133}
134Done
135