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