Written in front: Recently I have learned PHP, if you like friends, you can come here to see. One-dimensional array: $ Array [0] = 0; $ array [1] = 1; $ array ["word"] = "Word"; $ array [] = 2; $ array [] = 3; for $ i = 0; $ i
Array Sort Example 1:
Arsort () Sort array
$ Var_array = array ("name", "Work", "address"); Arsort ($ VAR_ARRAY); reset ($ VAR_ARRAY ); for ($ I = 0; $ I <3; $ I ) {$ TEMP = Each ($ VAR_ARRAY); Echo "$ TEMP [key] => $ TEMP [Value]
";}?> < BR> Example 2:
Sort () The index of the associated array does not exist, the array elements are sorted in the Dictionary.
$ var_array = array ("name", "Work", "address"); Sort ($ VAR_AARRAY); RESET ($ VAR_ARRAY); For ($ I = 0; $ I <3; $ I ) {$ TEMP = Each ($ VAR_ARRAY); Echo "$ TEMP [key] => $ TEMP [value ]
";}?>
Example 3:
Ksort () array in accordance with the keyword dictionary number, the corresponding relationship between keywords and values does not change.
$ var_Array = Array ("Name" => "Joe", "Work" => "teacher", "SEX" => "Male"); Ksort ($ VAR_ARRAY); RESET ($ VAR_ARRAY); for ($ I = 0; $ I <3; $ I ) {$ TEMP = Each ($ VAR_ARRAY); Echo "$ TEMP [key] = $ TEMP [Value]
";}?>
Example 4:
Asort ) Press the array
$ Var_Array = array ("name" => "joe", "work" => "teacher", "sex" => "Male"); Asort ($ VAR_ARRAY) Reset ($ VAR_ARRAY); For ($ I = 0; $ I <3; $ I ) {$ TEMP = Each ($ VAR_ARRAY); Echo "$ TEMP [key] => $ TEMP [Value]
}?>
Example 5: Rsort: Array elements Arrange in reverse sequence in dictionary.
$ var_Array = array ("name" => "joe", "Work" => "teacher", "SEX" => "Male"); RSORT ($ VAR_AARRAY); RESET ($ VAR_ARRAY); for ($ I = 0; $ I <3; $ I ) {$ TEMP = Each ($ VAR_AARRAY); Echo "$ TEMP [Key] = $ TEMP [Value]
";}?>