1--TEST-- 2Test sort() function : usage variations - sort mixed values, 'sort_flag' as default/SORT_REGULAR (OK to fail as result is unpredectable) 3--FILE-- 4<?php 5/* 6 * testing sort() by providing mixed value array for $array argument with following flag values. 7 * flag value as default 8 * SORT_REGULAR - compare items normally 9*/ 10 11echo "*** Testing sort() : usage variations ***\n"; 12 13// mixed value array 14$mixed_values = array ( 15 array(), 16 array(array(33, -5, 6), array(11), array(22, -55), array() ), 17 -4, "4", 4.00, "b", "5", -2, -2.0, -2.98989, "-.9", "True", "", 18 NULL, "ab", "abcd", 0.0, -0, "abcd\x00abcd\x00abcd", '', true, false 19); 20 21echo "\n-- Testing sort() by supplying mixed value array, 'flag' value is default --\n"; 22$temp_array = $mixed_values; 23var_dump(sort($temp_array) ); 24var_dump($temp_array); 25 26echo "\n-- Testing sort() by supplying mixed value array, 'flag' value is SORT_REGULAR --\n"; 27$temp_array = $mixed_values; 28var_dump(sort($temp_array, SORT_REGULAR) ); 29var_dump($temp_array); 30 31echo "Done\n"; 32?> 33--EXPECTF-- 34*** Testing sort() : usage variations *** 35 36-- Testing sort() by supplying mixed value array, 'flag' value is default -- 37bool(true) 38array(22) { 39 [0]=> 40 string(0) "" 41 [1]=> 42 NULL 43 [2]=> 44 string(0) "" 45 [3]=> 46 float(0) 47 [4]=> 48 bool(false) 49 [5]=> 50 int(-4) 51 [6]=> 52 float(-2.98989) 53 [7]=> 54 int(-2) 55 [8]=> 56 float(-2) 57 [9]=> 58 string(3) "-.9" 59 [10]=> 60 int(0) 61 [11]=> 62 string(1) "4" 63 [12]=> 64 float(4) 65 [13]=> 66 string(1) "5" 67 [14]=> 68 string(4) "True" 69 [15]=> 70 string(2) "ab" 71 [16]=> 72 string(4) "abcd" 73 [17]=> 74 string(14) "abcd%0abcd%0abcd" 75 [18]=> 76 string(1) "b" 77 [19]=> 78 array(0) { 79 } 80 [20]=> 81 array(4) { 82 [0]=> 83 array(3) { 84 [0]=> 85 int(33) 86 [1]=> 87 int(-5) 88 [2]=> 89 int(6) 90 } 91 [1]=> 92 array(1) { 93 [0]=> 94 int(11) 95 } 96 [2]=> 97 array(2) { 98 [0]=> 99 int(22) 100 [1]=> 101 int(-55) 102 } 103 [3]=> 104 array(0) { 105 } 106 } 107 [21]=> 108 bool(true) 109} 110 111-- Testing sort() by supplying mixed value array, 'flag' value is SORT_REGULAR -- 112bool(true) 113array(22) { 114 [0]=> 115 string(0) "" 116 [1]=> 117 NULL 118 [2]=> 119 string(0) "" 120 [3]=> 121 float(0) 122 [4]=> 123 bool(false) 124 [5]=> 125 int(-4) 126 [6]=> 127 float(-2.98989) 128 [7]=> 129 int(-2) 130 [8]=> 131 float(-2) 132 [9]=> 133 string(3) "-.9" 134 [10]=> 135 int(0) 136 [11]=> 137 string(1) "4" 138 [12]=> 139 float(4) 140 [13]=> 141 string(1) "5" 142 [14]=> 143 string(4) "True" 144 [15]=> 145 string(2) "ab" 146 [16]=> 147 string(4) "abcd" 148 [17]=> 149 string(14) "abcd%0abcd%0abcd" 150 [18]=> 151 string(1) "b" 152 [19]=> 153 array(0) { 154 } 155 [20]=> 156 array(4) { 157 [0]=> 158 array(3) { 159 [0]=> 160 int(33) 161 [1]=> 162 int(-5) 163 [2]=> 164 int(6) 165 } 166 [1]=> 167 array(1) { 168 [0]=> 169 int(11) 170 } 171 [2]=> 172 array(2) { 173 [0]=> 174 int(22) 175 [1]=> 176 int(-55) 177 } 178 [3]=> 179 array(0) { 180 } 181 } 182 [21]=> 183 bool(true) 184} 185Done 186