1--TEST--
2Test range() function (variation-1)
3--INI--
4precision=14
5--FILE--
6<?php
7
8echo "\n*** Testing range() with various low and high values ***";
9$low_arr = array( "ABCD", -10.5555, TRUE, NULL, FALSE, "", array(1,2));
10$high_arr = array( "ABCD", -10.5555, TRUE, NULL, FALSE, "", array(1,2));
11
12for( $i = 0; $i < count($low_arr); $i++) {
13  for( $j = 0; $j < count($high_arr); $j++) {
14    echo @"\n-- creating an array with low = '$low_arr[$i]' and high = '$high_arr[$j]' --\n";
15    var_dump( range( $low_arr[$i], $high_arr[$j] ) );
16  }
17}
18
19echo "\n*** Possible variatins with steps ***\n";
20var_dump( range( 1, 5, TRUE ) );
21try {
22    var_dump( range( 1, 5, array(1, 2) ) );
23} catch (TypeError $e) {
24    echo $e->getMessage(), "\n";
25}
26
27echo "Done\n";
28?>
29--EXPECT--
30*** Testing range() with various low and high values ***
31-- creating an array with low = 'ABCD' and high = 'ABCD' --
32array(1) {
33  [0]=>
34  string(1) "A"
35}
36
37-- creating an array with low = 'ABCD' and high = '-10.5555' --
38array(11) {
39  [0]=>
40  float(0)
41  [1]=>
42  float(-1)
43  [2]=>
44  float(-2)
45  [3]=>
46  float(-3)
47  [4]=>
48  float(-4)
49  [5]=>
50  float(-5)
51  [6]=>
52  float(-6)
53  [7]=>
54  float(-7)
55  [8]=>
56  float(-8)
57  [9]=>
58  float(-9)
59  [10]=>
60  float(-10)
61}
62
63-- creating an array with low = 'ABCD' and high = '1' --
64array(2) {
65  [0]=>
66  int(0)
67  [1]=>
68  int(1)
69}
70
71-- creating an array with low = 'ABCD' and high = '' --
72array(1) {
73  [0]=>
74  int(0)
75}
76
77-- creating an array with low = 'ABCD' and high = '' --
78array(1) {
79  [0]=>
80  int(0)
81}
82
83-- creating an array with low = 'ABCD' and high = '' --
84array(1) {
85  [0]=>
86  int(0)
87}
88
89-- creating an array with low = 'ABCD' and high = 'Array' --
90array(2) {
91  [0]=>
92  int(0)
93  [1]=>
94  int(1)
95}
96
97-- creating an array with low = '-10.5555' and high = 'ABCD' --
98array(11) {
99  [0]=>
100  float(-10.5555)
101  [1]=>
102  float(-9.5555)
103  [2]=>
104  float(-8.5555)
105  [3]=>
106  float(-7.5555)
107  [4]=>
108  float(-6.5555)
109  [5]=>
110  float(-5.5555)
111  [6]=>
112  float(-4.5555)
113  [7]=>
114  float(-3.5555000000000003)
115  [8]=>
116  float(-2.5555000000000003)
117  [9]=>
118  float(-1.5555000000000003)
119  [10]=>
120  float(-0.5555000000000003)
121}
122
123-- creating an array with low = '-10.5555' and high = '-10.5555' --
124array(1) {
125  [0]=>
126  float(-10.5555)
127}
128
129-- creating an array with low = '-10.5555' and high = '1' --
130array(12) {
131  [0]=>
132  float(-10.5555)
133  [1]=>
134  float(-9.5555)
135  [2]=>
136  float(-8.5555)
137  [3]=>
138  float(-7.5555)
139  [4]=>
140  float(-6.5555)
141  [5]=>
142  float(-5.5555)
143  [6]=>
144  float(-4.5555)
145  [7]=>
146  float(-3.5555000000000003)
147  [8]=>
148  float(-2.5555000000000003)
149  [9]=>
150  float(-1.5555000000000003)
151  [10]=>
152  float(-0.5555000000000003)
153  [11]=>
154  float(0.4444999999999997)
155}
156
157-- creating an array with low = '-10.5555' and high = '' --
158array(11) {
159  [0]=>
160  float(-10.5555)
161  [1]=>
162  float(-9.5555)
163  [2]=>
164  float(-8.5555)
165  [3]=>
166  float(-7.5555)
167  [4]=>
168  float(-6.5555)
169  [5]=>
170  float(-5.5555)
171  [6]=>
172  float(-4.5555)
173  [7]=>
174  float(-3.5555000000000003)
175  [8]=>
176  float(-2.5555000000000003)
177  [9]=>
178  float(-1.5555000000000003)
179  [10]=>
180  float(-0.5555000000000003)
181}
182
183-- creating an array with low = '-10.5555' and high = '' --
184array(11) {
185  [0]=>
186  float(-10.5555)
187  [1]=>
188  float(-9.5555)
189  [2]=>
190  float(-8.5555)
191  [3]=>
192  float(-7.5555)
193  [4]=>
194  float(-6.5555)
195  [5]=>
196  float(-5.5555)
197  [6]=>
198  float(-4.5555)
199  [7]=>
200  float(-3.5555000000000003)
201  [8]=>
202  float(-2.5555000000000003)
203  [9]=>
204  float(-1.5555000000000003)
205  [10]=>
206  float(-0.5555000000000003)
207}
208
209-- creating an array with low = '-10.5555' and high = '' --
210array(11) {
211  [0]=>
212  float(-10.5555)
213  [1]=>
214  float(-9.5555)
215  [2]=>
216  float(-8.5555)
217  [3]=>
218  float(-7.5555)
219  [4]=>
220  float(-6.5555)
221  [5]=>
222  float(-5.5555)
223  [6]=>
224  float(-4.5555)
225  [7]=>
226  float(-3.5555000000000003)
227  [8]=>
228  float(-2.5555000000000003)
229  [9]=>
230  float(-1.5555000000000003)
231  [10]=>
232  float(-0.5555000000000003)
233}
234
235-- creating an array with low = '-10.5555' and high = 'Array' --
236array(12) {
237  [0]=>
238  float(-10.5555)
239  [1]=>
240  float(-9.5555)
241  [2]=>
242  float(-8.5555)
243  [3]=>
244  float(-7.5555)
245  [4]=>
246  float(-6.5555)
247  [5]=>
248  float(-5.5555)
249  [6]=>
250  float(-4.5555)
251  [7]=>
252  float(-3.5555000000000003)
253  [8]=>
254  float(-2.5555000000000003)
255  [9]=>
256  float(-1.5555000000000003)
257  [10]=>
258  float(-0.5555000000000003)
259  [11]=>
260  float(0.4444999999999997)
261}
262
263-- creating an array with low = '1' and high = 'ABCD' --
264array(2) {
265  [0]=>
266  int(1)
267  [1]=>
268  int(0)
269}
270
271-- creating an array with low = '1' and high = '-10.5555' --
272array(12) {
273  [0]=>
274  float(1)
275  [1]=>
276  float(0)
277  [2]=>
278  float(-1)
279  [3]=>
280  float(-2)
281  [4]=>
282  float(-3)
283  [5]=>
284  float(-4)
285  [6]=>
286  float(-5)
287  [7]=>
288  float(-6)
289  [8]=>
290  float(-7)
291  [9]=>
292  float(-8)
293  [10]=>
294  float(-9)
295  [11]=>
296  float(-10)
297}
298
299-- creating an array with low = '1' and high = '1' --
300array(1) {
301  [0]=>
302  int(1)
303}
304
305-- creating an array with low = '1' and high = '' --
306array(2) {
307  [0]=>
308  int(1)
309  [1]=>
310  int(0)
311}
312
313-- creating an array with low = '1' and high = '' --
314array(2) {
315  [0]=>
316  int(1)
317  [1]=>
318  int(0)
319}
320
321-- creating an array with low = '1' and high = '' --
322array(2) {
323  [0]=>
324  int(1)
325  [1]=>
326  int(0)
327}
328
329-- creating an array with low = '1' and high = 'Array' --
330array(1) {
331  [0]=>
332  int(1)
333}
334
335-- creating an array with low = '' and high = 'ABCD' --
336array(1) {
337  [0]=>
338  int(0)
339}
340
341-- creating an array with low = '' and high = '-10.5555' --
342array(11) {
343  [0]=>
344  float(0)
345  [1]=>
346  float(-1)
347  [2]=>
348  float(-2)
349  [3]=>
350  float(-3)
351  [4]=>
352  float(-4)
353  [5]=>
354  float(-5)
355  [6]=>
356  float(-6)
357  [7]=>
358  float(-7)
359  [8]=>
360  float(-8)
361  [9]=>
362  float(-9)
363  [10]=>
364  float(-10)
365}
366
367-- creating an array with low = '' and high = '1' --
368array(2) {
369  [0]=>
370  int(0)
371  [1]=>
372  int(1)
373}
374
375-- creating an array with low = '' and high = '' --
376array(1) {
377  [0]=>
378  int(0)
379}
380
381-- creating an array with low = '' and high = '' --
382array(1) {
383  [0]=>
384  int(0)
385}
386
387-- creating an array with low = '' and high = '' --
388array(1) {
389  [0]=>
390  int(0)
391}
392
393-- creating an array with low = '' and high = 'Array' --
394array(2) {
395  [0]=>
396  int(0)
397  [1]=>
398  int(1)
399}
400
401-- creating an array with low = '' and high = 'ABCD' --
402array(1) {
403  [0]=>
404  int(0)
405}
406
407-- creating an array with low = '' and high = '-10.5555' --
408array(11) {
409  [0]=>
410  float(0)
411  [1]=>
412  float(-1)
413  [2]=>
414  float(-2)
415  [3]=>
416  float(-3)
417  [4]=>
418  float(-4)
419  [5]=>
420  float(-5)
421  [6]=>
422  float(-6)
423  [7]=>
424  float(-7)
425  [8]=>
426  float(-8)
427  [9]=>
428  float(-9)
429  [10]=>
430  float(-10)
431}
432
433-- creating an array with low = '' and high = '1' --
434array(2) {
435  [0]=>
436  int(0)
437  [1]=>
438  int(1)
439}
440
441-- creating an array with low = '' and high = '' --
442array(1) {
443  [0]=>
444  int(0)
445}
446
447-- creating an array with low = '' and high = '' --
448array(1) {
449  [0]=>
450  int(0)
451}
452
453-- creating an array with low = '' and high = '' --
454array(1) {
455  [0]=>
456  int(0)
457}
458
459-- creating an array with low = '' and high = 'Array' --
460array(2) {
461  [0]=>
462  int(0)
463  [1]=>
464  int(1)
465}
466
467-- creating an array with low = '' and high = 'ABCD' --
468array(1) {
469  [0]=>
470  int(0)
471}
472
473-- creating an array with low = '' and high = '-10.5555' --
474array(11) {
475  [0]=>
476  float(0)
477  [1]=>
478  float(-1)
479  [2]=>
480  float(-2)
481  [3]=>
482  float(-3)
483  [4]=>
484  float(-4)
485  [5]=>
486  float(-5)
487  [6]=>
488  float(-6)
489  [7]=>
490  float(-7)
491  [8]=>
492  float(-8)
493  [9]=>
494  float(-9)
495  [10]=>
496  float(-10)
497}
498
499-- creating an array with low = '' and high = '1' --
500array(2) {
501  [0]=>
502  int(0)
503  [1]=>
504  int(1)
505}
506
507-- creating an array with low = '' and high = '' --
508array(1) {
509  [0]=>
510  int(0)
511}
512
513-- creating an array with low = '' and high = '' --
514array(1) {
515  [0]=>
516  int(0)
517}
518
519-- creating an array with low = '' and high = '' --
520array(1) {
521  [0]=>
522  int(0)
523}
524
525-- creating an array with low = '' and high = 'Array' --
526array(2) {
527  [0]=>
528  int(0)
529  [1]=>
530  int(1)
531}
532
533-- creating an array with low = 'Array' and high = 'ABCD' --
534array(2) {
535  [0]=>
536  int(1)
537  [1]=>
538  int(0)
539}
540
541-- creating an array with low = 'Array' and high = '-10.5555' --
542array(12) {
543  [0]=>
544  float(1)
545  [1]=>
546  float(0)
547  [2]=>
548  float(-1)
549  [3]=>
550  float(-2)
551  [4]=>
552  float(-3)
553  [5]=>
554  float(-4)
555  [6]=>
556  float(-5)
557  [7]=>
558  float(-6)
559  [8]=>
560  float(-7)
561  [9]=>
562  float(-8)
563  [10]=>
564  float(-9)
565  [11]=>
566  float(-10)
567}
568
569-- creating an array with low = 'Array' and high = '1' --
570array(1) {
571  [0]=>
572  int(1)
573}
574
575-- creating an array with low = 'Array' and high = '' --
576array(2) {
577  [0]=>
578  int(1)
579  [1]=>
580  int(0)
581}
582
583-- creating an array with low = 'Array' and high = '' --
584array(2) {
585  [0]=>
586  int(1)
587  [1]=>
588  int(0)
589}
590
591-- creating an array with low = 'Array' and high = '' --
592array(2) {
593  [0]=>
594  int(1)
595  [1]=>
596  int(0)
597}
598
599-- creating an array with low = 'Array' and high = 'Array' --
600array(1) {
601  [0]=>
602  int(1)
603}
604
605*** Possible variatins with steps ***
606array(5) {
607  [0]=>
608  int(1)
609  [1]=>
610  int(2)
611  [2]=>
612  int(3)
613  [3]=>
614  int(4)
615  [4]=>
616  int(5)
617}
618range(): Argument #3 ($step) must be of type int|float, array given
619Done
620