Note: This function assigns the new key name to the cells in the array. The original key name is deleted.
Returns TRUE if successful, otherwise FALSE.
$my _array = Array ("A" = "Dog", "b" = "Cat", "c" = "Horse");
Sort ($my _array);
Print_r ($my _array);
?>
Output
Array
(
[0] = Cat
[1] = Dog
[2] = Horse
)
The Asort () function sorts the array and maintains the index relationship. It is primarily used to sort the associative arrays that are important for the cell order.
The Second optional parameter contains an additional sort ID.
Returns TRUE if successful, otherwise FALSE.
$my _array = Array ("A" = "Dog", "b" = "Cat", "c" = "Horse");
Asort ($my _array);
Print_r ($my _array);
?>
Output
Array
(
[B] = Cat
[A] = Dog
[C] = Horse
)
The Ksort () function sorts the array by key name, preserving the original key for the array value.
The Second optional parameter contains an additional sort flag. Www.jbxue.com
Returns TRUE if successful, otherwise FALSE is returned.
$my _array = Array ("A" = "Dog", "b" = "Cat", "c" = "Horse");
Ksort ($my _array);
Print_r ($my _array);
?>
Output
Array
(
[A] = Dog
[B] = Cat
[C] = Horse
)
The above three functions differ in the key name, the key value, whether to change the index or not
>>> articles you may be interested in:
< span="">
< span="">
< span="">
< span="">
< span="">
< span="">
< span="">
< span="">
http://www.bkjia.com/PHPjc/738552.html www.bkjia.com true http://www.bkjia.com/PHPjc/738552.html techarticle Note: This function assigns the new key name to the cells in the array. The original key name is deleted. Returns TRUE if successful, otherwise FALSE. php $my _array = Array ("A" = "Dog", "B ...