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  [""]=>
44  string(0) ""
45  [-2]=>
46  float(-2.98989)
47  ["-.9"]=>
48  string(3) "-.9"
49  [0]=>
50  float(0.001)
51  [4]=>
52  float(4.01)
53  [5]=>
54  string(1) "5"
55  ["True"]=>
56  string(4) "True"
57  ["ab"]=>
58  string(2) "ab"
59  ["abcd"]=>
60  string(4) "abcd"
61  ["abcd%0abcd%0abcd"]=>
62  string(14) "abcd%0abcd%0abcd"
63  ["array1"]=>
64  array(0) {
65  }
66  ["array2"]=>
67  array(4) {
68    ["sub_array[2,1]"]=>
69    array(3) {
70      [0]=>
71      int(33)
72      [1]=>
73      int(-5)
74      [2]=>
75      int(6)
76    }
77    ["sub_array[2,2]"]=>
78    array(1) {
79      [0]=>
80      int(11)
81    }
82    ["sub_array[2,3]"]=>
83    array(2) {
84      [0]=>
85      int(22)
86      [1]=>
87      int(-55)
88    }
89    ["sub_array[2,4]"]=>
90    array(0) {
91    }
92  }
93  ["b"]=>
94  string(1) "b"
95}
96
97-- Testing ksort() by supplying mixed value array, 'flag' value is SORT_REGULAR --
98bool(true)
99array(13) {
100  [""]=>
101  string(0) ""
102  [-2]=>
103  float(-2.98989)
104  ["-.9"]=>
105  string(3) "-.9"
106  [0]=>
107  float(0.001)
108  [4]=>
109  float(4.01)
110  [5]=>
111  string(1) "5"
112  ["True"]=>
113  string(4) "True"
114  ["ab"]=>
115  string(2) "ab"
116  ["abcd"]=>
117  string(4) "abcd"
118  ["abcd%0abcd%0abcd"]=>
119  string(14) "abcd%0abcd%0abcd"
120  ["array1"]=>
121  array(0) {
122  }
123  ["array2"]=>
124  array(4) {
125    ["sub_array[2,1]"]=>
126    array(3) {
127      [0]=>
128      int(33)
129      [1]=>
130      int(-5)
131      [2]=>
132      int(6)
133    }
134    ["sub_array[2,2]"]=>
135    array(1) {
136      [0]=>
137      int(11)
138    }
139    ["sub_array[2,3]"]=>
140    array(2) {
141      [0]=>
142      int(22)
143      [1]=>
144      int(-55)
145    }
146    ["sub_array[2,4]"]=>
147    array(0) {
148    }
149  }
150  ["b"]=>
151  string(1) "b"
152}
153Done
154