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