1--TEST-- 2Test sort() function : usage variations - sort strings 3--FILE-- 4<?php 5 6$array = [ 7 "lemoN", 8 "Orange", 9 "banana", 10 "apple", 11 "Test", 12 "TTTT", 13 "ttt", 14 "ww", 15 "x", 16 "X", 17 "oraNGe", 18 "BANANA", 19]; 20 21echo "Default flag\n"; 22$temp_array = $array; 23var_dump(sort($temp_array)); // expecting : bool(true) 24var_dump($temp_array); 25 26echo "SORT_REGULAR\n"; 27$temp_array = $array; 28var_dump(sort($temp_array, SORT_REGULAR)); // expecting : bool(true) 29var_dump($temp_array); 30 31echo "SORT_STRING\n"; 32$temp_array = $array; 33var_dump(sort($temp_array, SORT_STRING)); // expecting : bool(true) 34var_dump($temp_array); 35 36?> 37--EXPECT-- 38Default flag 39bool(true) 40array(12) { 41 [0]=> 42 string(6) "BANANA" 43 [1]=> 44 string(6) "Orange" 45 [2]=> 46 string(4) "TTTT" 47 [3]=> 48 string(4) "Test" 49 [4]=> 50 string(1) "X" 51 [5]=> 52 string(5) "apple" 53 [6]=> 54 string(6) "banana" 55 [7]=> 56 string(5) "lemoN" 57 [8]=> 58 string(6) "oraNGe" 59 [9]=> 60 string(3) "ttt" 61 [10]=> 62 string(2) "ww" 63 [11]=> 64 string(1) "x" 65} 66SORT_REGULAR 67bool(true) 68array(12) { 69 [0]=> 70 string(6) "BANANA" 71 [1]=> 72 string(6) "Orange" 73 [2]=> 74 string(4) "TTTT" 75 [3]=> 76 string(4) "Test" 77 [4]=> 78 string(1) "X" 79 [5]=> 80 string(5) "apple" 81 [6]=> 82 string(6) "banana" 83 [7]=> 84 string(5) "lemoN" 85 [8]=> 86 string(6) "oraNGe" 87 [9]=> 88 string(3) "ttt" 89 [10]=> 90 string(2) "ww" 91 [11]=> 92 string(1) "x" 93} 94SORT_STRING 95bool(true) 96array(12) { 97 [0]=> 98 string(6) "BANANA" 99 [1]=> 100 string(6) "Orange" 101 [2]=> 102 string(4) "TTTT" 103 [3]=> 104 string(4) "Test" 105 [4]=> 106 string(1) "X" 107 [5]=> 108 string(5) "apple" 109 [6]=> 110 string(6) "banana" 111 [7]=> 112 string(5) "lemoN" 113 [8]=> 114 string(6) "oraNGe" 115 [9]=> 116 string(3) "ttt" 117 [10]=> 118 string(2) "ww" 119 [11]=> 120 string(1) "x" 121} 122