1--TEST-- 2Test krsort() function : usage variations - sort bool values 3--FILE-- 4<?php 5/* Prototype : bool krsort ( array &$array [, int $sort_flags] ) 6 * Description: Sort an array by key in reverse order, maintaining key to data correlation 7 * Source code: ext/standard/array.c 8*/ 9 10/* 11 * testing krsort() by providing array of boolean values for $array argument with following flag values: 12 * 1.flag value as defualt 13 * 2.SORT_REGULAR - compare items normally 14*/ 15 16echo "*** Testing krsort() : usage variations ***\n"; 17 18// bool value array 19$bool_values = array (true => true, false => false, TRUE => TRUE, FALSE => FALSE); 20 21echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is defualt --\n"; 22$temp_array = $bool_values; 23var_dump(krsort($temp_array) ); 24var_dump($temp_array); 25 26echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_REGULAR --\n"; 27$temp_array = $bool_values; 28var_dump(krsort($temp_array, SORT_REGULAR) ); 29var_dump($temp_array); 30 31echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_NUMERIC --\n"; 32$temp_array = $bool_values; 33var_dump(krsort($temp_array, SORT_NUMERIC) ); 34var_dump($temp_array); 35 36echo "\n-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_STRING --\n"; 37$temp_array = $bool_values; 38var_dump(krsort($temp_array, SORT_STRING) ); 39var_dump($temp_array); 40 41echo "Done\n"; 42?> 43--EXPECTF-- 44*** Testing krsort() : usage variations *** 45 46-- Testing krsort() by supplying boolean value array, 'flag' value is defualt -- 47bool(true) 48array(2) { 49 [1]=> 50 bool(true) 51 [0]=> 52 bool(false) 53} 54 55-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_REGULAR -- 56bool(true) 57array(2) { 58 [1]=> 59 bool(true) 60 [0]=> 61 bool(false) 62} 63 64-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_NUMERIC -- 65bool(true) 66array(2) { 67 [1]=> 68 bool(true) 69 [0]=> 70 bool(false) 71} 72 73-- Testing krsort() by supplying boolean value array, 'flag' value is SORT_STRING -- 74bool(true) 75array(2) { 76 [1]=> 77 bool(true) 78 [0]=> 79 bool(false) 80} 81Done