1--TEST--
2Test array_change_key_case() function
3--FILE--
4<?php
5/* Prototype: array array_change_key_case ( array $input [, int $case] )
6   Description: Changes the keys in the input array to be all lowercase
7   or uppercase. The change depends on the last optional case parameter.
8   You can pass two constants there, CASE_UPPER and CASE_LOWER(default).
9   The function will leave number indices as is.
10*/
11$arrays = array (
12  array (),
13  array (0),
14  array (1),
15  array (-1),
16  array (0, 2, 3, 4, 5),
17  array (1, 2, 3, 4, 5),
18  array ("" => 1),
19  array ("a" => 1),
20  array ("Z" => 1),
21  array ("one" => 1),
22  array ("ONE" => 1),
23  array ("OnE" => 1),
24  array ("oNe" => 1),
25  array ("one" => 1, "two" => 2),
26  array ("ONE" => 1, "two" => 2),
27  array ("OnE" => 1, "two" => 2),
28  array ("oNe" => 1, "two" => 2),
29  array ("one" => 1, "TWO" => 2),
30  array ("ONE" => 1, "TWO" => 2),
31  array ("OnE" => 1, "TWO" => 2),
32  array ("oNe" => 1, "TWO" => 2),
33  array ("one" => 1, "TwO" => 2),
34  array ("ONE" => 1, "TwO" => 2),
35  array ("OnE" => 1, "TwO" => 2),
36  array ("oNe" => 1, "TwO" => 2),
37  array ("one" => 1, "tWo" => 2),
38  array ("ONE" => 1, "tWo" => 2),
39  array ("OnE" => 1, "tWo" => 2),
40  array ("oNe" => 1, "tWo" => 2),
41  array ("one" => 1, 2),
42  array ("ONE" => 1, 2),
43  array ("OnE" => 1, 2),
44  array ("oNe" => 1, 2),
45  array ("ONE" => 1, "TWO" => 2, "THREE" => 3, "FOUR" => "four"),
46  array ("one" => 1, "two" => 2, "three" => 3, "four" => "FOUR"),
47  array ("ONE" => 1, "TWO" => 2, "three" => 3, "four" => "FOUR"),
48  array ("one" => 1, "two" => 2, "THREE" => 3, "FOUR" => "four")
49);
50
51echo "*** Testing basic operations ***\n";
52$loop_counter = 1;
53foreach ($arrays as $item) {
54        echo "** Iteration $loop_counter **\n"; $loop_counter++;
55	var_dump(array_change_key_case($item));
56	var_dump(array_change_key_case($item, CASE_UPPER));
57	var_dump(array_change_key_case($item, CASE_LOWER));
58	echo "\n";
59}
60
61echo "end\n";
62?>
63--EXPECT--
64*** Testing basic operations ***
65** Iteration 1 **
66array(0) {
67}
68array(0) {
69}
70array(0) {
71}
72
73** Iteration 2 **
74array(1) {
75  [0]=>
76  int(0)
77}
78array(1) {
79  [0]=>
80  int(0)
81}
82array(1) {
83  [0]=>
84  int(0)
85}
86
87** Iteration 3 **
88array(1) {
89  [0]=>
90  int(1)
91}
92array(1) {
93  [0]=>
94  int(1)
95}
96array(1) {
97  [0]=>
98  int(1)
99}
100
101** Iteration 4 **
102array(1) {
103  [0]=>
104  int(-1)
105}
106array(1) {
107  [0]=>
108  int(-1)
109}
110array(1) {
111  [0]=>
112  int(-1)
113}
114
115** Iteration 5 **
116array(5) {
117  [0]=>
118  int(0)
119  [1]=>
120  int(2)
121  [2]=>
122  int(3)
123  [3]=>
124  int(4)
125  [4]=>
126  int(5)
127}
128array(5) {
129  [0]=>
130  int(0)
131  [1]=>
132  int(2)
133  [2]=>
134  int(3)
135  [3]=>
136  int(4)
137  [4]=>
138  int(5)
139}
140array(5) {
141  [0]=>
142  int(0)
143  [1]=>
144  int(2)
145  [2]=>
146  int(3)
147  [3]=>
148  int(4)
149  [4]=>
150  int(5)
151}
152
153** Iteration 6 **
154array(5) {
155  [0]=>
156  int(1)
157  [1]=>
158  int(2)
159  [2]=>
160  int(3)
161  [3]=>
162  int(4)
163  [4]=>
164  int(5)
165}
166array(5) {
167  [0]=>
168  int(1)
169  [1]=>
170  int(2)
171  [2]=>
172  int(3)
173  [3]=>
174  int(4)
175  [4]=>
176  int(5)
177}
178array(5) {
179  [0]=>
180  int(1)
181  [1]=>
182  int(2)
183  [2]=>
184  int(3)
185  [3]=>
186  int(4)
187  [4]=>
188  int(5)
189}
190
191** Iteration 7 **
192array(1) {
193  [""]=>
194  int(1)
195}
196array(1) {
197  [""]=>
198  int(1)
199}
200array(1) {
201  [""]=>
202  int(1)
203}
204
205** Iteration 8 **
206array(1) {
207  ["a"]=>
208  int(1)
209}
210array(1) {
211  ["A"]=>
212  int(1)
213}
214array(1) {
215  ["a"]=>
216  int(1)
217}
218
219** Iteration 9 **
220array(1) {
221  ["z"]=>
222  int(1)
223}
224array(1) {
225  ["Z"]=>
226  int(1)
227}
228array(1) {
229  ["z"]=>
230  int(1)
231}
232
233** Iteration 10 **
234array(1) {
235  ["one"]=>
236  int(1)
237}
238array(1) {
239  ["ONE"]=>
240  int(1)
241}
242array(1) {
243  ["one"]=>
244  int(1)
245}
246
247** Iteration 11 **
248array(1) {
249  ["one"]=>
250  int(1)
251}
252array(1) {
253  ["ONE"]=>
254  int(1)
255}
256array(1) {
257  ["one"]=>
258  int(1)
259}
260
261** Iteration 12 **
262array(1) {
263  ["one"]=>
264  int(1)
265}
266array(1) {
267  ["ONE"]=>
268  int(1)
269}
270array(1) {
271  ["one"]=>
272  int(1)
273}
274
275** Iteration 13 **
276array(1) {
277  ["one"]=>
278  int(1)
279}
280array(1) {
281  ["ONE"]=>
282  int(1)
283}
284array(1) {
285  ["one"]=>
286  int(1)
287}
288
289** Iteration 14 **
290array(2) {
291  ["one"]=>
292  int(1)
293  ["two"]=>
294  int(2)
295}
296array(2) {
297  ["ONE"]=>
298  int(1)
299  ["TWO"]=>
300  int(2)
301}
302array(2) {
303  ["one"]=>
304  int(1)
305  ["two"]=>
306  int(2)
307}
308
309** Iteration 15 **
310array(2) {
311  ["one"]=>
312  int(1)
313  ["two"]=>
314  int(2)
315}
316array(2) {
317  ["ONE"]=>
318  int(1)
319  ["TWO"]=>
320  int(2)
321}
322array(2) {
323  ["one"]=>
324  int(1)
325  ["two"]=>
326  int(2)
327}
328
329** Iteration 16 **
330array(2) {
331  ["one"]=>
332  int(1)
333  ["two"]=>
334  int(2)
335}
336array(2) {
337  ["ONE"]=>
338  int(1)
339  ["TWO"]=>
340  int(2)
341}
342array(2) {
343  ["one"]=>
344  int(1)
345  ["two"]=>
346  int(2)
347}
348
349** Iteration 17 **
350array(2) {
351  ["one"]=>
352  int(1)
353  ["two"]=>
354  int(2)
355}
356array(2) {
357  ["ONE"]=>
358  int(1)
359  ["TWO"]=>
360  int(2)
361}
362array(2) {
363  ["one"]=>
364  int(1)
365  ["two"]=>
366  int(2)
367}
368
369** Iteration 18 **
370array(2) {
371  ["one"]=>
372  int(1)
373  ["two"]=>
374  int(2)
375}
376array(2) {
377  ["ONE"]=>
378  int(1)
379  ["TWO"]=>
380  int(2)
381}
382array(2) {
383  ["one"]=>
384  int(1)
385  ["two"]=>
386  int(2)
387}
388
389** Iteration 19 **
390array(2) {
391  ["one"]=>
392  int(1)
393  ["two"]=>
394  int(2)
395}
396array(2) {
397  ["ONE"]=>
398  int(1)
399  ["TWO"]=>
400  int(2)
401}
402array(2) {
403  ["one"]=>
404  int(1)
405  ["two"]=>
406  int(2)
407}
408
409** Iteration 20 **
410array(2) {
411  ["one"]=>
412  int(1)
413  ["two"]=>
414  int(2)
415}
416array(2) {
417  ["ONE"]=>
418  int(1)
419  ["TWO"]=>
420  int(2)
421}
422array(2) {
423  ["one"]=>
424  int(1)
425  ["two"]=>
426  int(2)
427}
428
429** Iteration 21 **
430array(2) {
431  ["one"]=>
432  int(1)
433  ["two"]=>
434  int(2)
435}
436array(2) {
437  ["ONE"]=>
438  int(1)
439  ["TWO"]=>
440  int(2)
441}
442array(2) {
443  ["one"]=>
444  int(1)
445  ["two"]=>
446  int(2)
447}
448
449** Iteration 22 **
450array(2) {
451  ["one"]=>
452  int(1)
453  ["two"]=>
454  int(2)
455}
456array(2) {
457  ["ONE"]=>
458  int(1)
459  ["TWO"]=>
460  int(2)
461}
462array(2) {
463  ["one"]=>
464  int(1)
465  ["two"]=>
466  int(2)
467}
468
469** Iteration 23 **
470array(2) {
471  ["one"]=>
472  int(1)
473  ["two"]=>
474  int(2)
475}
476array(2) {
477  ["ONE"]=>
478  int(1)
479  ["TWO"]=>
480  int(2)
481}
482array(2) {
483  ["one"]=>
484  int(1)
485  ["two"]=>
486  int(2)
487}
488
489** Iteration 24 **
490array(2) {
491  ["one"]=>
492  int(1)
493  ["two"]=>
494  int(2)
495}
496array(2) {
497  ["ONE"]=>
498  int(1)
499  ["TWO"]=>
500  int(2)
501}
502array(2) {
503  ["one"]=>
504  int(1)
505  ["two"]=>
506  int(2)
507}
508
509** Iteration 25 **
510array(2) {
511  ["one"]=>
512  int(1)
513  ["two"]=>
514  int(2)
515}
516array(2) {
517  ["ONE"]=>
518  int(1)
519  ["TWO"]=>
520  int(2)
521}
522array(2) {
523  ["one"]=>
524  int(1)
525  ["two"]=>
526  int(2)
527}
528
529** Iteration 26 **
530array(2) {
531  ["one"]=>
532  int(1)
533  ["two"]=>
534  int(2)
535}
536array(2) {
537  ["ONE"]=>
538  int(1)
539  ["TWO"]=>
540  int(2)
541}
542array(2) {
543  ["one"]=>
544  int(1)
545  ["two"]=>
546  int(2)
547}
548
549** Iteration 27 **
550array(2) {
551  ["one"]=>
552  int(1)
553  ["two"]=>
554  int(2)
555}
556array(2) {
557  ["ONE"]=>
558  int(1)
559  ["TWO"]=>
560  int(2)
561}
562array(2) {
563  ["one"]=>
564  int(1)
565  ["two"]=>
566  int(2)
567}
568
569** Iteration 28 **
570array(2) {
571  ["one"]=>
572  int(1)
573  ["two"]=>
574  int(2)
575}
576array(2) {
577  ["ONE"]=>
578  int(1)
579  ["TWO"]=>
580  int(2)
581}
582array(2) {
583  ["one"]=>
584  int(1)
585  ["two"]=>
586  int(2)
587}
588
589** Iteration 29 **
590array(2) {
591  ["one"]=>
592  int(1)
593  ["two"]=>
594  int(2)
595}
596array(2) {
597  ["ONE"]=>
598  int(1)
599  ["TWO"]=>
600  int(2)
601}
602array(2) {
603  ["one"]=>
604  int(1)
605  ["two"]=>
606  int(2)
607}
608
609** Iteration 30 **
610array(2) {
611  ["one"]=>
612  int(1)
613  [0]=>
614  int(2)
615}
616array(2) {
617  ["ONE"]=>
618  int(1)
619  [0]=>
620  int(2)
621}
622array(2) {
623  ["one"]=>
624  int(1)
625  [0]=>
626  int(2)
627}
628
629** Iteration 31 **
630array(2) {
631  ["one"]=>
632  int(1)
633  [0]=>
634  int(2)
635}
636array(2) {
637  ["ONE"]=>
638  int(1)
639  [0]=>
640  int(2)
641}
642array(2) {
643  ["one"]=>
644  int(1)
645  [0]=>
646  int(2)
647}
648
649** Iteration 32 **
650array(2) {
651  ["one"]=>
652  int(1)
653  [0]=>
654  int(2)
655}
656array(2) {
657  ["ONE"]=>
658  int(1)
659  [0]=>
660  int(2)
661}
662array(2) {
663  ["one"]=>
664  int(1)
665  [0]=>
666  int(2)
667}
668
669** Iteration 33 **
670array(2) {
671  ["one"]=>
672  int(1)
673  [0]=>
674  int(2)
675}
676array(2) {
677  ["ONE"]=>
678  int(1)
679  [0]=>
680  int(2)
681}
682array(2) {
683  ["one"]=>
684  int(1)
685  [0]=>
686  int(2)
687}
688
689** Iteration 34 **
690array(4) {
691  ["one"]=>
692  int(1)
693  ["two"]=>
694  int(2)
695  ["three"]=>
696  int(3)
697  ["four"]=>
698  string(4) "four"
699}
700array(4) {
701  ["ONE"]=>
702  int(1)
703  ["TWO"]=>
704  int(2)
705  ["THREE"]=>
706  int(3)
707  ["FOUR"]=>
708  string(4) "four"
709}
710array(4) {
711  ["one"]=>
712  int(1)
713  ["two"]=>
714  int(2)
715  ["three"]=>
716  int(3)
717  ["four"]=>
718  string(4) "four"
719}
720
721** Iteration 35 **
722array(4) {
723  ["one"]=>
724  int(1)
725  ["two"]=>
726  int(2)
727  ["three"]=>
728  int(3)
729  ["four"]=>
730  string(4) "FOUR"
731}
732array(4) {
733  ["ONE"]=>
734  int(1)
735  ["TWO"]=>
736  int(2)
737  ["THREE"]=>
738  int(3)
739  ["FOUR"]=>
740  string(4) "FOUR"
741}
742array(4) {
743  ["one"]=>
744  int(1)
745  ["two"]=>
746  int(2)
747  ["three"]=>
748  int(3)
749  ["four"]=>
750  string(4) "FOUR"
751}
752
753** Iteration 36 **
754array(4) {
755  ["one"]=>
756  int(1)
757  ["two"]=>
758  int(2)
759  ["three"]=>
760  int(3)
761  ["four"]=>
762  string(4) "FOUR"
763}
764array(4) {
765  ["ONE"]=>
766  int(1)
767  ["TWO"]=>
768  int(2)
769  ["THREE"]=>
770  int(3)
771  ["FOUR"]=>
772  string(4) "FOUR"
773}
774array(4) {
775  ["one"]=>
776  int(1)
777  ["two"]=>
778  int(2)
779  ["three"]=>
780  int(3)
781  ["four"]=>
782  string(4) "FOUR"
783}
784
785** Iteration 37 **
786array(4) {
787  ["one"]=>
788  int(1)
789  ["two"]=>
790  int(2)
791  ["three"]=>
792  int(3)
793  ["four"]=>
794  string(4) "four"
795}
796array(4) {
797  ["ONE"]=>
798  int(1)
799  ["TWO"]=>
800  int(2)
801  ["THREE"]=>
802  int(3)
803  ["FOUR"]=>
804  string(4) "four"
805}
806array(4) {
807  ["one"]=>
808  int(1)
809  ["two"]=>
810  int(2)
811  ["three"]=>
812  int(3)
813  ["four"]=>
814  string(4) "four"
815}
816
817end
818