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