1--TEST--
2Test asort() 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 asort() 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 asort() : 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 asort() by supplying mixed value array, 'flag' value is default --\n";
26$temp_array = $mixed_values;
27var_dump( asort($temp_array) );
28var_dump($temp_array);
29
30echo "\n-- Testing asort() by supplying mixed value array, 'flag' value is SORT_REGULAR --\n";
31$temp_array = $mixed_values;
32var_dump( asort($temp_array, SORT_REGULAR) );
33var_dump($temp_array);
34
35echo "Done\n";
36?>
37--EXPECTF--
38*** Testing asort() : usage variations ***
39
40-- Testing asort() 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  ["b"]=>
64  string(1) "b"
65  ["array1"]=>
66  array(0) {
67  }
68  ["array2"]=>
69  array(4) {
70    ["sub_array[2,1]"]=>
71    array(3) {
72      [0]=>
73      int(33)
74      [1]=>
75      int(-5)
76      [2]=>
77      int(6)
78    }
79    ["sub_array[2,2]"]=>
80    array(1) {
81      [0]=>
82      int(11)
83    }
84    ["sub_array[2,3]"]=>
85    array(2) {
86      [0]=>
87      int(22)
88      [1]=>
89      int(-55)
90    }
91    ["sub_array[2,4]"]=>
92    array(0) {
93    }
94  }
95}
96
97-- Testing asort() 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  ["b"]=>
121  string(1) "b"
122  ["array1"]=>
123  array(0) {
124  }
125  ["array2"]=>
126  array(4) {
127    ["sub_array[2,1]"]=>
128    array(3) {
129      [0]=>
130      int(33)
131      [1]=>
132      int(-5)
133      [2]=>
134      int(6)
135    }
136    ["sub_array[2,2]"]=>
137    array(1) {
138      [0]=>
139      int(11)
140    }
141    ["sub_array[2,3]"]=>
142    array(2) {
143      [0]=>
144      int(22)
145      [1]=>
146      int(-55)
147    }
148    ["sub_array[2,4]"]=>
149    array(0) {
150    }
151  }
152}
153Done
154