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