1--TEST--
2Test array_udiff_assoc() function : usage variation
3--FILE--
4<?php
5/* Prototype  : array array_udiff_assoc(array arr1, array arr2 [, array ...], callback key_comp_func)
6 * Description: Returns the entries of arr1 that have values which are not present in any of the others arguments but do additional checks whether the keys are equal. Keys are compared by user supplied function.
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_udiff_assoc() : usage variation ***\n";
12
13// Initialise function arguments not being substituted (if any)
14$arr1 = array(1, 2);
15$arr2 = array(1, 2);
16
17include('compare_function.inc');
18$key_comp_func = 'compare_function';
19
20//get an unset variable
21$unset_var = 10;
22unset ($unset_var);
23
24// define some classes
25class classWithToString
26{
27	public function __toString() {
28		return "Class A object";
29	}
30}
31
32class classWithoutToString
33{
34}
35
36// heredoc string
37$heredoc = <<<EOT
38hello world
39EOT;
40
41// add arrays
42$index_array = array (1, 2, 3);
43$assoc_array = array ('one' => 1, 'two' => 2);
44
45//array of values to iterate over
46$inputs = array(
47
48      // int data
49      'int 0' => 0,
50      'int 1' => 1,
51      'int 12345' => 12345,
52      'int -12345' => -2345,
53
54      // float data
55      'float 10.5' => 10.5,
56      'float -10.5' => -10.5,
57      'float 12.3456789000e10' => 12.3456789000e10,
58      'float -12.3456789000e10' => -12.3456789000e10,
59      'float .5' => .5,
60
61      // null data
62      'uppercase NULL' => NULL,
63      'lowercase null' => null,
64
65      // boolean data
66      'lowercase true' => true,
67      'lowercase false' =>false,
68      'uppercase TRUE' =>TRUE,
69      'uppercase FALSE' =>FALSE,
70
71      // empty data
72      'empty string DQ' => "",
73      'empty string SQ' => '',
74
75      // string data
76      'string DQ' => "string",
77      'string SQ' => 'string',
78      'mixed case string' => "sTrInG",
79      'heredoc' => $heredoc,
80
81      // object data
82      'instance of classWithToString' => new classWithToString(),
83      'instance of classWithoutToString' => new classWithoutToString(),
84
85      // undefined data
86      'undefined var' => @$undefined_var,
87
88      // unset data
89      'unset var' => @$unset_var,
90);
91
92// loop through each element of the array for ...
93
94foreach($inputs as $key =>$value) {
95      echo "\n--$key--\n";
96      var_dump( array_udiff_assoc($arr1, $arr2, $value, $key_comp_func) );
97};
98
99?>
100===DONE===
101--EXPECTF--
102*** Testing array_udiff_assoc() : usage variation ***
103
104--int 0--
105
106Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
107NULL
108
109--int 1--
110
111Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
112NULL
113
114--int 12345--
115
116Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
117NULL
118
119--int -12345--
120
121Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
122NULL
123
124--float 10.5--
125
126Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
127NULL
128
129--float -10.5--
130
131Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
132NULL
133
134--float 12.3456789000e10--
135
136Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
137NULL
138
139--float -12.3456789000e10--
140
141Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
142NULL
143
144--float .5--
145
146Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
147NULL
148
149--uppercase NULL--
150
151Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
152NULL
153
154--lowercase null--
155
156Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
157NULL
158
159--lowercase true--
160
161Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
162NULL
163
164--lowercase false--
165
166Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
167NULL
168
169--uppercase TRUE--
170
171Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
172NULL
173
174--uppercase FALSE--
175
176Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
177NULL
178
179--empty string DQ--
180
181Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
182NULL
183
184--empty string SQ--
185
186Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
187NULL
188
189--string DQ--
190
191Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
192NULL
193
194--string SQ--
195
196Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
197NULL
198
199--mixed case string--
200
201Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
202NULL
203
204--heredoc--
205
206Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
207NULL
208
209--instance of classWithToString--
210
211Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
212NULL
213
214--instance of classWithoutToString--
215
216Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
217NULL
218
219--undefined var--
220
221Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
222NULL
223
224--unset var--
225
226Warning: array_udiff_assoc(): Argument #3 is not an array in %sarray_udiff_assoc_variation4.php on line %d
227NULL
228===DONE===
229