1--TEST--
2Test array_diff_assoc() function : usage variations - compare integers, floats and strings
3--FILE--
4<?php
5/* Prototype  : array array_diff_assoc(array $arr1, array $arr2 [, array ...])
6 * Description: Returns the entries of arr1 that have values which are not present
7 * in any of the others arguments but do additional checks whether the keys are equal
8 * Source code: ext/standard/array.c
9 */
10
11/*
12 * Test how array_diff_assoc compares integers, floats and string
13 */
14
15echo "*** Testing array_diff_assoc() : usage variations ***\n";
16$arr_default_int = array(1, 2, 3, 'a');
17$arr_float = array(0 => 1.00, 1.00 => 2.00, 2.00 => 3.00, 'b');
18$arr_string = array('1', '2', '3', 'c');
19$arr_string_float = array('0' => '1.00', '1.00' => '2.00', '2.00' => '3.00', 'd');
20
21echo "-- Result of comparing integers and floating point numbers: --\n";
22var_dump(array_diff_assoc($arr_default_int, $arr_float));
23var_dump(array_diff_assoc($arr_float, $arr_default_int));
24
25echo "-- Result of comparing integers and strings containing an integers : --\n";
26var_dump(array_diff_assoc($arr_default_int, $arr_string));
27var_dump(array_diff_assoc($arr_string, $arr_default_int));
28
29echo "-- Result of comparing integers and strings containing floating points : --\n";
30var_dump(array_diff_assoc($arr_default_int, $arr_string_float));
31var_dump(array_diff_assoc($arr_string_float, $arr_default_int));
32
33echo "-- Result of comparing floating points and strings containing integers : --\n";
34var_dump(array_diff_assoc($arr_float, $arr_string));
35var_dump(array_diff_assoc($arr_string, $arr_float));
36
37echo "-- Result of comparing floating points and strings containing floating point: --\n";
38var_dump(array_diff_assoc($arr_float, $arr_string_float));
39var_dump(array_diff_assoc($arr_string_float, $arr_float));
40
41echo "-- Result of comparing strings containing integers and strings containing floating points : --\n";
42var_dump(array_diff_assoc($arr_string, $arr_string_float));
43var_dump(array_diff_assoc($arr_string_float, $arr_string));
44
45echo "-- Result of comparing more than two arrays: --\n";
46var_dump(array_diff_assoc($arr_default_int, $arr_float, $arr_string, $arr_string_float));
47
48echo "Done";
49?>
50--EXPECT--
51*** Testing array_diff_assoc() : usage variations ***
52-- Result of comparing integers and floating point numbers: --
53array(1) {
54  [3]=>
55  string(1) "a"
56}
57array(1) {
58  [3]=>
59  string(1) "b"
60}
61-- Result of comparing integers and strings containing an integers : --
62array(1) {
63  [3]=>
64  string(1) "a"
65}
66array(1) {
67  [3]=>
68  string(1) "c"
69}
70-- Result of comparing integers and strings containing floating points : --
71array(4) {
72  [0]=>
73  int(1)
74  [1]=>
75  int(2)
76  [2]=>
77  int(3)
78  [3]=>
79  string(1) "a"
80}
81array(4) {
82  [0]=>
83  string(4) "1.00"
84  ["1.00"]=>
85  string(4) "2.00"
86  ["2.00"]=>
87  string(4) "3.00"
88  [1]=>
89  string(1) "d"
90}
91-- Result of comparing floating points and strings containing integers : --
92array(1) {
93  [3]=>
94  string(1) "b"
95}
96array(1) {
97  [3]=>
98  string(1) "c"
99}
100-- Result of comparing floating points and strings containing floating point: --
101array(4) {
102  [0]=>
103  float(1)
104  [1]=>
105  float(2)
106  [2]=>
107  float(3)
108  [3]=>
109  string(1) "b"
110}
111array(4) {
112  [0]=>
113  string(4) "1.00"
114  ["1.00"]=>
115  string(4) "2.00"
116  ["2.00"]=>
117  string(4) "3.00"
118  [1]=>
119  string(1) "d"
120}
121-- Result of comparing strings containing integers and strings containing floating points : --
122array(4) {
123  [0]=>
124  string(1) "1"
125  [1]=>
126  string(1) "2"
127  [2]=>
128  string(1) "3"
129  [3]=>
130  string(1) "c"
131}
132array(4) {
133  [0]=>
134  string(4) "1.00"
135  ["1.00"]=>
136  string(4) "2.00"
137  ["2.00"]=>
138  string(4) "3.00"
139  [1]=>
140  string(1) "d"
141}
142-- Result of comparing more than two arrays: --
143array(1) {
144  [3]=>
145  string(1) "a"
146}
147Done
148