1--TEST--
2Test ksort() function : usage variations - sort mixed values, 'sort_flags' as default/SORT_REGULAR (OK to fail as result is unpredectable)
3--FILE--
4<?php
5/*
6 * testing ksort() by providing array of mixed values for $array argument with following flag values:
7 *  1.flag value as default
8 *  2.SORT_REGULAR - compare items normally
9*/
10
11echo "*** Testing ksort() : usage variations ***\n";
12
13// mixed value array with different key values
14$mixed_values = array (
15  "array1" => array(),
16  "array2" => array ( "sub_array[2,1]" => array(33,-5,6), "sub_array[2,2]" => array(11),
17                      "sub_array[2,3]" => array(22,-55), "sub_array[2,4]" => array()
18                    ),
19  4 => 4, "4" => "4", 4 => 4.01, "b" => "b", "5" => "5", -2 => -2, -2 => -2.01,
20  -2 => -2.98989, "-.9" => "-.9", "True" => "True", "" =>  "", NULL => NULL,
21  "ab" => "ab", "abcd" => "abcd", 0 => 0.01, -0 => -0, '' => '' ,
22  "abcd\x00abcd\x00abcd" => "abcd\x00abcd\x00abcd", 0 => 0.001
23);
24
25echo "\n-- Testing ksort() by supplying mixed value array, 'flag' value is default --\n";
26$temp_array = $mixed_values;
27var_dump( ksort($temp_array) );
28var_dump($temp_array);
29
30echo "\n-- Testing ksort() by supplying mixed value array, 'flag' value is SORT_REGULAR --\n";
31$temp_array = $mixed_values;
32var_dump( ksort($temp_array, SORT_REGULAR) );
33var_dump($temp_array);
34
35echo "Done\n";
36?>
37--EXPECTF--
38*** Testing ksort() : usage variations ***
39
40-- Testing ksort() by supplying mixed value array, 'flag' value is default --
41bool(true)
42array(13) {
43  [-2]=>
44  float(-2.98989)
45  [""]=>
46  string(0) ""
47  ["-.9"]=>
48  string(3) "-.9"
49  ["True"]=>
50  string(4) "True"
51  ["ab"]=>
52  string(2) "ab"
53  ["abcd"]=>
54  string(4) "abcd"
55  ["array1"]=>
56  array(0) {
57  }
58  ["array2"]=>
59  array(4) {
60    ["sub_array[2,1]"]=>
61    array(3) {
62      [0]=>
63      int(33)
64      [1]=>
65      int(-5)
66      [2]=>
67      int(6)
68    }
69    ["sub_array[2,2]"]=>
70    array(1) {
71      [0]=>
72      int(11)
73    }
74    ["sub_array[2,3]"]=>
75    array(2) {
76      [0]=>
77      int(22)
78      [1]=>
79      int(-55)
80    }
81    ["sub_array[2,4]"]=>
82    array(0) {
83    }
84  }
85  ["b"]=>
86  string(1) "b"
87  [0]=>
88  float(0.001)
89  ["abcd%0abcd%0abcd"]=>
90  string(14) "abcd%0abcd%0abcd"
91  [4]=>
92  float(4.01)
93  [5]=>
94  string(1) "5"
95}
96
97-- Testing ksort() by supplying mixed value array, 'flag' value is SORT_REGULAR --
98bool(true)
99array(13) {
100  [-2]=>
101  float(-2.98989)
102  [""]=>
103  string(0) ""
104  ["-.9"]=>
105  string(3) "-.9"
106  ["True"]=>
107  string(4) "True"
108  ["ab"]=>
109  string(2) "ab"
110  ["abcd"]=>
111  string(4) "abcd"
112  ["array1"]=>
113  array(0) {
114  }
115  ["array2"]=>
116  array(4) {
117    ["sub_array[2,1]"]=>
118    array(3) {
119      [0]=>
120      int(33)
121      [1]=>
122      int(-5)
123      [2]=>
124      int(6)
125    }
126    ["sub_array[2,2]"]=>
127    array(1) {
128      [0]=>
129      int(11)
130    }
131    ["sub_array[2,3]"]=>
132    array(2) {
133      [0]=>
134      int(22)
135      [1]=>
136      int(-55)
137    }
138    ["sub_array[2,4]"]=>
139    array(0) {
140    }
141  }
142  ["b"]=>
143  string(1) "b"
144  [0]=>
145  float(0.001)
146  ["abcd%0abcd%0abcd"]=>
147  string(14) "abcd%0abcd%0abcd"
148  [4]=>
149  float(4.01)
150  [5]=>
151  string(1) "5"
152}
153Done
154