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