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