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