1--TEST--
2Test rsort() function : usage variations - mixed array
3--FILE--
4<?php
5/* Prototype  : bool rsort(array &$array_arg [, int $sort_flags])
6 * Description: Sort an array in reverse order
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Pass rsort() an array of different data types to test behaviour
12 */
13
14echo "*** Testing rsort() : variation ***\n";
15
16// mixed value array
17$mixed_values = array (
18  array(),
19  array( array(33, -5, 6),
20         array(11),
21         array(22, -55),
22         array()
23        ),
24  -4, "4", 4.00, "b", "5", -2, -2.0, -2.98989, "-.9", "True", "",
25  NULL, "ab", "abcd", 0.0, -0, "abcd\x00abcd\x00abcd", '', true, false
26);
27
28echo "\n-- Sort flag = default --\n";
29$temp_array = $mixed_values;
30var_dump(rsort($temp_array) );
31var_dump($temp_array);
32
33echo "\n-- Sort flag = SORT_REGULAR --\n";
34$temp_array = $mixed_values;
35var_dump(rsort($temp_array, SORT_REGULAR) );
36var_dump($temp_array);
37
38echo "Done";
39?>
40--EXPECTF--
41*** Testing rsort() : variation ***
42
43-- Sort flag = default --
44bool(true)
45array(22) {
46  [0]=>
47  array(4) {
48    [0]=>
49    array(3) {
50      [0]=>
51      int(33)
52      [1]=>
53      int(-5)
54      [2]=>
55      int(6)
56    }
57    [1]=>
58    array(1) {
59      [0]=>
60      int(11)
61    }
62    [2]=>
63    array(2) {
64      [0]=>
65      int(22)
66      [1]=>
67      int(-55)
68    }
69    [3]=>
70    array(0) {
71    }
72  }
73  [1]=>
74  array(0) {
75  }
76  [2]=>
77  string(1) "b"
78  [3]=>
79  string(14) "abcd�abcd�abcd"
80  [4]=>
81  string(4) "abcd"
82  [5]=>
83  string(2) "ab"
84  [6]=>
85  string(4) "True"
86  [7]=>
87  string(1) "5"
88  [8]=>
89  bool(true)
90  [9]=>
91  string(1) "4"
92  [10]=>
93  float(4)
94  [11]=>
95  float(0)
96  [12]=>
97  int(0)
98  [13]=>
99  string(3) "-.9"
100  [14]=>
101  string(0) ""
102  [15]=>
103  string(0) ""
104  [16]=>
105  int(-2)
106  [17]=>
107  float(-2)
108  [18]=>
109  float(-2.98989)
110  [19]=>
111  int(-4)
112  [20]=>
113  bool(false)
114  [21]=>
115  NULL
116}
117
118-- Sort flag = SORT_REGULAR --
119bool(true)
120array(22) {
121  [0]=>
122  array(4) {
123    [0]=>
124    array(3) {
125      [0]=>
126      int(33)
127      [1]=>
128      int(-5)
129      [2]=>
130      int(6)
131    }
132    [1]=>
133    array(1) {
134      [0]=>
135      int(11)
136    }
137    [2]=>
138    array(2) {
139      [0]=>
140      int(22)
141      [1]=>
142      int(-55)
143    }
144    [3]=>
145    array(0) {
146    }
147  }
148  [1]=>
149  array(0) {
150  }
151  [2]=>
152  string(1) "b"
153  [3]=>
154  string(14) "abcd�abcd�abcd"
155  [4]=>
156  string(4) "abcd"
157  [5]=>
158  string(2) "ab"
159  [6]=>
160  string(4) "True"
161  [7]=>
162  string(1) "5"
163  [8]=>
164  bool(true)
165  [9]=>
166  string(1) "4"
167  [10]=>
168  float(4)
169  [11]=>
170  float(0)
171  [12]=>
172  int(0)
173  [13]=>
174  string(3) "-.9"
175  [14]=>
176  string(0) ""
177  [15]=>
178  string(0) ""
179  [16]=>
180  int(-2)
181  [17]=>
182  float(-2)
183  [18]=>
184  float(-2.98989)
185  [19]=>
186  int(-4)
187  [20]=>
188  bool(false)
189  [21]=>
190  NULL
191}
192Done