1--TEST--
2Test arsort() function : usage variations - unexpected values for 'array_arg' argument
3--FILE--
4<?php
5/* Prototype  : bool arsort(array &array_arg [, int sort_flags])
6 * Description: Sort an array and maintain index association
7                Elements will be arranged from highest to lowest when this function has completed.
8 * Source code: ext/standard/array.c
9*/
10
11/*
12 * testing arsort() by providing different unexpected values for array argument with following flag values.
13 * 1. flag value as defualt
14 * 2. SORT_REGULAR - compare items normally
15 * 3. SORT_NUMERIC - compare items numerically
16 * 4. SORT_STRING - compare items as strings
17*/
18
19echo "*** Testing arsort() : usage variations ***\n";
20
21// get an unset variable
22$unset_var = 10;
23unset ($unset_var);
24
25// resource variable
26$fp = fopen(__FILE__, "r");
27
28//array of values with indices to iterate over
29$unexpected_values = array (
30
31  // int data
32  0 => 0,
33  1 => 1,
34  2 => 12345,
35  3 => -2345,
36
37  // float data
38  4 => 10.5,
39  5 => -10.5,
40  6 => 10.5e3,
41  7 => 10.6E-2,
42  8 => .5,
43
44  // null data
45  9 => NULL,
46  10 => null,
47
48  // boolean data
49  11 => true,
50  12 => false,
51  13 => TRUE,
52  14 => FALSE,
53
54  // empty data
55  15 => "",
56  16 => '',
57
58  // string data
59  17 => "string",
60  18 => 'string',
61
62  // object data
63  19 => new stdclass(),
64
65  // undefined data
66  20 => @undefined_var,
67
68  // unset data
69  21 => @unset_var,
70
71  // resource variable
72  22 => $fp
73
74);
75
76// loop though each element of the array and check the working of arsort()
77// when $array argument is supplied with different values from $unexpected_values
78echo "\n-- Testing arsort() by supplying different unexpected values for 'array' argument --\n";
79echo "\n-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --\n";
80
81$counter = 1;
82for($index = 0; $index < count($unexpected_values); $index ++) {
83  echo "-- Iteration $counter --\n";
84  $value = $unexpected_values [$index];
85  var_dump( arsort($value) ); // expecting : bool(false)
86  var_dump( arsort($value, SORT_REGULAR) ); // expecting : bool(false)
87  var_dump( arsort($value, SORT_NUMERIC) ); // expecting : bool(false)
88  var_dump( arsort($value, SORT_STRING) ); // expecting : bool(false)
89  $counter++;
90}
91
92echo "Done";
93?>
94--EXPECTF--
95*** Testing arsort() : usage variations ***
96
97-- Testing arsort() by supplying different unexpected values for 'array' argument --
98
99-- Flag values are defualt, SORT_REGULAR, SORT_NUMERIC, SORT_STRING --
100-- Iteration 1 --
101
102Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
103bool(false)
104
105Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
106bool(false)
107
108Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
109bool(false)
110
111Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
112bool(false)
113-- Iteration 2 --
114
115Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
116bool(false)
117
118Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
119bool(false)
120
121Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
122bool(false)
123
124Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
125bool(false)
126-- Iteration 3 --
127
128Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
129bool(false)
130
131Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
132bool(false)
133
134Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
135bool(false)
136
137Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
138bool(false)
139-- Iteration 4 --
140
141Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
142bool(false)
143
144Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
145bool(false)
146
147Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
148bool(false)
149
150Warning: arsort() expects parameter 1 to be array, integer given in %sarsort_variation1.php on line %d
151bool(false)
152-- Iteration 5 --
153
154Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
155bool(false)
156
157Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
158bool(false)
159
160Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
161bool(false)
162
163Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
164bool(false)
165-- Iteration 6 --
166
167Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
168bool(false)
169
170Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
171bool(false)
172
173Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
174bool(false)
175
176Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
177bool(false)
178-- Iteration 7 --
179
180Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
181bool(false)
182
183Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
184bool(false)
185
186Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
187bool(false)
188
189Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
190bool(false)
191-- Iteration 8 --
192
193Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
194bool(false)
195
196Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
197bool(false)
198
199Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
200bool(false)
201
202Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
203bool(false)
204-- Iteration 9 --
205
206Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
207bool(false)
208
209Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
210bool(false)
211
212Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
213bool(false)
214
215Warning: arsort() expects parameter 1 to be array, float given in %sarsort_variation1.php on line %d
216bool(false)
217-- Iteration 10 --
218
219Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
220bool(false)
221
222Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
223bool(false)
224
225Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
226bool(false)
227
228Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
229bool(false)
230-- Iteration 11 --
231
232Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
233bool(false)
234
235Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
236bool(false)
237
238Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
239bool(false)
240
241Warning: arsort() expects parameter 1 to be array, null given in %sarsort_variation1.php on line %d
242bool(false)
243-- Iteration 12 --
244
245Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
246bool(false)
247
248Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
249bool(false)
250
251Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
252bool(false)
253
254Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
255bool(false)
256-- Iteration 13 --
257
258Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
259bool(false)
260
261Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
262bool(false)
263
264Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
265bool(false)
266
267Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
268bool(false)
269-- Iteration 14 --
270
271Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
272bool(false)
273
274Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
275bool(false)
276
277Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
278bool(false)
279
280Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
281bool(false)
282-- Iteration 15 --
283
284Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
285bool(false)
286
287Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
288bool(false)
289
290Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
291bool(false)
292
293Warning: arsort() expects parameter 1 to be array, boolean given in %sarsort_variation1.php on line %d
294bool(false)
295-- Iteration 16 --
296
297Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
298bool(false)
299
300Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
301bool(false)
302
303Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
304bool(false)
305
306Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
307bool(false)
308-- Iteration 17 --
309
310Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
311bool(false)
312
313Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
314bool(false)
315
316Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
317bool(false)
318
319Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
320bool(false)
321-- Iteration 18 --
322
323Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
324bool(false)
325
326Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
327bool(false)
328
329Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
330bool(false)
331
332Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
333bool(false)
334-- Iteration 19 --
335
336Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
337bool(false)
338
339Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
340bool(false)
341
342Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
343bool(false)
344
345Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
346bool(false)
347-- Iteration 20 --
348
349Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
350bool(false)
351
352Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
353bool(false)
354
355Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
356bool(false)
357
358Warning: arsort() expects parameter 1 to be array, object given in %sarsort_variation1.php on line %d
359bool(false)
360-- Iteration 21 --
361
362Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
363bool(false)
364
365Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
366bool(false)
367
368Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
369bool(false)
370
371Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
372bool(false)
373-- Iteration 22 --
374
375Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
376bool(false)
377
378Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
379bool(false)
380
381Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
382bool(false)
383
384Warning: arsort() expects parameter 1 to be array, string given in %sarsort_variation1.php on line %d
385bool(false)
386-- Iteration 23 --
387
388Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
389bool(false)
390
391Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
392bool(false)
393
394Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
395bool(false)
396
397Warning: arsort() expects parameter 1 to be array, resource given in %sarsort_variation1.php on line %d
398bool(false)
399Done
400