1--TEST-- 2Test asort() function : usage variations - sort bool values 3--FILE-- 4<?php 5/* Prototype : bool asort ( array &$array [, int $sort_flags] ) 6 * Description: This function asorts an array. 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 bool value array for $array argument with following flag values. 13 * flag value as defualt 14 * SORT_REGULAR - compare items normally 15*/ 16 17echo "*** Testing asort() : usage variations ***\n"; 18 19// bool value array 20$bool_values = array (1 => true, 2 => false, 3 => TRUE, 4 => FALSE); 21 22echo "\n-- Testing asort() by supplying bool value array, 'flag' value is defualt --\n"; 23$temp_array = $bool_values; 24var_dump(asort($temp_array) ); 25var_dump($temp_array); 26 27echo "\n-- Testing asort() by supplying bool value array, 'flag' value is SORT_REGULAR --\n"; 28$temp_array = $bool_values; 29var_dump(asort($temp_array, SORT_REGULAR) ); 30var_dump($temp_array); 31 32echo "\n-- Testing asort() by supplying bool value array, 'flag' value is SORT_NUMERIC --\n"; 33$temp_array = $bool_values; 34var_dump(asort($temp_array, SORT_NUMERIC) ); 35var_dump($temp_array); 36 37echo "\n-- Testing asort() by supplying bool value array, 'flag' value is SORT_STRING --\n"; 38$temp_array = $bool_values; 39var_dump(asort($temp_array, SORT_STRING) ); 40var_dump($temp_array); 41 42echo "Done\n"; 43?> 44--EXPECTF-- 45*** Testing asort() : usage variations *** 46 47-- Testing asort() by supplying bool value array, 'flag' value is defualt -- 48bool(true) 49array(4) { 50 [4]=> 51 bool(false) 52 [2]=> 53 bool(false) 54 [1]=> 55 bool(true) 56 [3]=> 57 bool(true) 58} 59 60-- Testing asort() by supplying bool value array, 'flag' value is SORT_REGULAR -- 61bool(true) 62array(4) { 63 [4]=> 64 bool(false) 65 [2]=> 66 bool(false) 67 [1]=> 68 bool(true) 69 [3]=> 70 bool(true) 71} 72 73-- Testing asort() by supplying bool value array, 'flag' value is SORT_NUMERIC -- 74bool(true) 75array(4) { 76 [4]=> 77 bool(false) 78 [2]=> 79 bool(false) 80 [1]=> 81 bool(true) 82 [3]=> 83 bool(true) 84} 85 86-- Testing asort() by supplying bool value array, 'flag' value is SORT_STRING -- 87bool(true) 88array(4) { 89 [4]=> 90 bool(false) 91 [2]=> 92 bool(false) 93 [1]=> 94 bool(true) 95 [3]=> 96 bool(true) 97} 98Done 99