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