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