1--TEST--
2Test sort() function : usage variations - sort boolean values
3--FILE--
4<?php
5/* Prototype  : bool sort ( array &$array [, int $sort_flags] )
6 * Description: This function sorts an array.
7                Elements will be arranged from lowest to highest when this function has completed.
8 * Source code: ext/standard/array.c
9*/
10
11/*
12 * testing sort() by providing bool value array for $array argument with following flag values.
13 * flag  value as defualt
14 * SORT_REGULAR - compare items normally
15*/
16
17echo "*** Testing sort() : usage variations ***\n";
18
19// bool value array
20$bool_values = array (true, false, TRUE, FALSE);
21
22echo "\n-- Testing sort() by supplying bool value array, 'flag' value is defualt --\n";
23$temp_array = $bool_values;
24var_dump(sort($temp_array) );
25var_dump($temp_array);
26
27echo "\n-- Testing sort() by supplying bool value array, 'flag' value is SORT_REGULAR --\n";
28$temp_array = $bool_values;
29var_dump(sort($temp_array, SORT_REGULAR) );
30var_dump($temp_array);
31
32echo "\n-- Testing sort() by supplying bool value array, 'flag' value is SORT_NUMERIC  --\n";
33$temp_array = $bool_values;
34var_dump(sort($temp_array, SORT_NUMERIC) );
35var_dump($temp_array);
36
37echo "\n-- Testing sort() by supplying bool value array, 'flag' value is SORT_STRING --\n";
38$temp_array = $bool_values;
39var_dump(sort($temp_array, SORT_STRING) );
40var_dump($temp_array);
41
42echo "Done\n";
43?>
44--EXPECTF--
45*** Testing sort() : usage variations ***
46
47-- Testing sort() by supplying bool value array, 'flag' value is defualt --
48bool(true)
49array(4) {
50  [0]=>
51  bool(false)
52  [1]=>
53  bool(false)
54  [2]=>
55  bool(true)
56  [3]=>
57  bool(true)
58}
59
60-- Testing sort() by supplying bool value array, 'flag' value is SORT_REGULAR --
61bool(true)
62array(4) {
63  [0]=>
64  bool(false)
65  [1]=>
66  bool(false)
67  [2]=>
68  bool(true)
69  [3]=>
70  bool(true)
71}
72
73-- Testing sort() by supplying bool value array, 'flag' value is SORT_NUMERIC  --
74bool(true)
75array(4) {
76  [0]=>
77  bool(false)
78  [1]=>
79  bool(false)
80  [2]=>
81  bool(true)
82  [3]=>
83  bool(true)
84}
85
86-- Testing sort() by supplying bool value array, 'flag' value is SORT_STRING --
87bool(true)
88array(4) {
89  [0]=>
90  bool(false)
91  [1]=>
92  bool(false)
93  [2]=>
94  bool(true)
95  [3]=>
96  bool(true)
97}
98Done
99