The PHP array sorts the element key names of the arrays in ascending order and keeps the index relationship, so a friend can refer to them.
This time this function is
The Ksort () function is sorted in ascending order by key name, preserving the original key for the array value.
The Second optional parameter contains an additional sort flag.
Returns TRUE if successful, otherwise FALSE is returned.
Grammar
Ksort (array,sorttype) parameter description
Array required. Specifies the array to sort.
SortType is optional. Specifies how the values of the array are arranged. Possible values:
Sort_regular-Default. Processed in their original type (without changing the type).
Sort_numeric-Handle the value as a number
Sort_string-handles the value as a string
Sort_locale_string-handles the value as a string, based on local settings *.
*: This value is new for PHP 4.4.0 and 5.0.2. Prior to PHP 6, the system's locale was used, which can be changed using setlocale (). From PHP 6, you must use the I18n_loc_set_default () function.
Example
The code is as follows |
Copy Code |
$my _array = Array ("e" = "Dog", "b" = "Cat", "c" = "Horse"); Ksort ($my _array); Print_r ($my _array); ?> output: Array ([b] = Cat [c] = Horse [E] = Sog) |
http://www.bkjia.com/PHPjc/629256.html www.bkjia.com true http://www.bkjia.com/PHPjc/629256.html techarticle The PHP array sorts the element key names of the arrays in ascending order and keeps the index relationship, so a friend can refer to them. This time this function is the Ksort () function Ascending by the name of the key in the array ...