1--TEST--
2Test ksort() function : usage variations - sort octal values
3--FILE--
4<?php
5/*
6 * testing ksort() by providing array of octal values for $array argument with following flag values:
7 *  1.flag value as default
8 *  2.SORT_REGULAR - compare items normally
9 *  3.SORT_NUMERIC - compare items numerically
10*/
11
12echo "*** Testing ksort() : usage variations ***\n";
13
14// an array containing unsorted octal values
15$unsorted_oct_array = array (
16  01235 => 01, 0321 => 02, 0345 => 03, 066 => 04, 0772 => 05,
17  077 => 06, -066 => -01, -0345 => -02, 0 => 0
18);
19
20echo "\n-- Testing ksort() by supplying octal value array, 'flag' value is default  --\n";
21$temp_array = $unsorted_oct_array;
22var_dump( ksort($temp_array) ); // expecting : bool(true)
23var_dump($temp_array);
24
25echo "\n-- Testing ksort() by supplying octal value array, 'flag' value is SORT_REGULAR  --\n";
26$temp_array = $unsorted_oct_array;
27var_dump( ksort($temp_array, SORT_REGULAR) ); // expecting : bool(true)
28var_dump($temp_array);
29
30echo "\n-- Testing ksort() by supplying octal value array, 'flag' value is SORT_NUMERIC  --\n";
31$temp_array = $unsorted_oct_array;
32var_dump( ksort($temp_array, SORT_NUMERIC) ); // expecting : bool(true)
33var_dump($temp_array);
34
35echo "Done\n";
36?>
37--EXPECT--
38*** Testing ksort() : usage variations ***
39
40-- Testing ksort() by supplying octal value array, 'flag' value is default  --
41bool(true)
42array(9) {
43  [-229]=>
44  int(-2)
45  [-54]=>
46  int(-1)
47  [0]=>
48  int(0)
49  [54]=>
50  int(4)
51  [63]=>
52  int(6)
53  [209]=>
54  int(2)
55  [229]=>
56  int(3)
57  [506]=>
58  int(5)
59  [669]=>
60  int(1)
61}
62
63-- Testing ksort() by supplying octal value array, 'flag' value is SORT_REGULAR  --
64bool(true)
65array(9) {
66  [-229]=>
67  int(-2)
68  [-54]=>
69  int(-1)
70  [0]=>
71  int(0)
72  [54]=>
73  int(4)
74  [63]=>
75  int(6)
76  [209]=>
77  int(2)
78  [229]=>
79  int(3)
80  [506]=>
81  int(5)
82  [669]=>
83  int(1)
84}
85
86-- Testing ksort() by supplying octal value array, 'flag' value is SORT_NUMERIC  --
87bool(true)
88array(9) {
89  [-229]=>
90  int(-2)
91  [-54]=>
92  int(-1)
93  [0]=>
94  int(0)
95  [54]=>
96  int(4)
97  [63]=>
98  int(6)
99  [209]=>
100  int(2)
101  [229]=>
102  int(3)
103  [506]=>
104  int(5)
105  [669]=>
106  int(1)
107}
108Done
109