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