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