Annotation of embedaddon/php/ext/standard/tests/array/array_diff_assoc_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
15: echo "*** 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:
21: echo "-- Result of comparing integers and floating point numbers: --\n";
22: var_dump(array_diff_assoc($arr_default_int, $arr_float));
23: var_dump(array_diff_assoc($arr_float, $arr_default_int));
24:
25: echo "-- Result of comparing integers and strings containing an integers : --\n";
26: var_dump(array_diff_assoc($arr_default_int, $arr_string));
27: var_dump(array_diff_assoc($arr_string, $arr_default_int));
28:
29: echo "-- Result of comparing integers and strings containing floating points : --\n";
30: var_dump(array_diff_assoc($arr_default_int, $arr_string_float));
31: var_dump(array_diff_assoc($arr_string_float, $arr_default_int));
32:
33: echo "-- Result of comparing floating points and strings containing integers : --\n";
34: var_dump(array_diff_assoc($arr_float, $arr_string));
35: var_dump(array_diff_assoc($arr_string, $arr_float));
36:
37: echo "-- Result of comparing floating points and strings containing floating point: --\n";
38: var_dump(array_diff_assoc($arr_float, $arr_string_float));
39: var_dump(array_diff_assoc($arr_string_float, $arr_float));
40:
41: echo "-- Result of comparing strings containing integers and strings containing floating points : --\n";
42: var_dump(array_diff_assoc($arr_string, $arr_string_float));
43: var_dump(array_diff_assoc($arr_string_float, $arr_string));
44:
45: echo "-- Result of comparing more than two arrays: --\n";
46: var_dump(array_diff_assoc($arr_default_int, $arr_float, $arr_string, $arr_string_float));
47:
48: echo "Done";
49: ?>
50: --EXPECTF--
51:
52: *** Testing array_diff_assoc() : usage variations ***
53: -- Result of comparing integers and floating point numbers: --
54: array(1) {
55: [3]=>
56: string(1) "a"
57: }
58: array(1) {
59: [3]=>
60: string(1) "b"
61: }
62: -- Result of comparing integers and strings containing an integers : --
63: array(1) {
64: [3]=>
65: string(1) "a"
66: }
67: array(1) {
68: [3]=>
69: string(1) "c"
70: }
71: -- Result of comparing integers and strings containing floating points : --
72: array(4) {
73: [0]=>
74: int(1)
75: [1]=>
76: int(2)
77: [2]=>
78: int(3)
79: [3]=>
80: string(1) "a"
81: }
82: array(4) {
83: [0]=>
84: string(4) "1.00"
85: ["1.00"]=>
86: string(4) "2.00"
87: ["2.00"]=>
88: string(4) "3.00"
89: [1]=>
90: string(1) "d"
91: }
92: -- Result of comparing floating points and strings containing integers : --
93: array(1) {
94: [3]=>
95: string(1) "b"
96: }
97: array(1) {
98: [3]=>
99: string(1) "c"
100: }
101: -- Result of comparing floating points and strings containing floating point: --
102: array(4) {
103: [0]=>
104: float(1)
105: [1]=>
106: float(2)
107: [2]=>
108: float(3)
109: [3]=>
110: string(1) "b"
111: }
112: array(4) {
113: [0]=>
114: string(4) "1.00"
115: ["1.00"]=>
116: string(4) "2.00"
117: ["2.00"]=>
118: string(4) "3.00"
119: [1]=>
120: string(1) "d"
121: }
122: -- Result of comparing strings containing integers and strings containing floating points : --
123: array(4) {
124: [0]=>
125: string(1) "1"
126: [1]=>
127: string(1) "2"
128: [2]=>
129: string(1) "3"
130: [3]=>
131: string(1) "c"
132: }
133: array(4) {
134: [0]=>
135: string(4) "1.00"
136: ["1.00"]=>
137: string(4) "2.00"
138: ["2.00"]=>
139: string(4) "3.00"
140: [1]=>
141: string(1) "d"
142: }
143: -- Result of comparing more than two arrays: --
144: array(1) {
145: [3]=>
146: string(1) "a"
147: }
148: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>