Asort () of php array function sequence-sort the element values of the array in ascending order to maintain the index relationship. Asort () definition and usage the asort () function sorts arrays and maintains the index relationship. It is mainly used to sort the arrays that are very important to the unit order. Optional second parameter package
Asort () definition and usage
The asort () function sorts arrays and maintains the index relationship. It is mainly used to sort the arrays that are very important to the unit order.
The second optional parameter contains an additional sorting identifier.
If the call succeeds, TRUE is returned. otherwise, FALSE is returned.
Syntax
Asort (array, sorttype) parameter description
Array is required. Input array.
Sorttype is optional. Specifies how to arrange the values of an array. Possible values:
SORT_REGULAR-default. Process with their original type (without changing the type ).
SORT_NUMERIC-process the value as a number
SORT_STRING-process the value as a string
SORT_LOCALE_STRING-process the value as a string based on local settings *.
*: This value is newly added to PHP 4.4.0 and 5.0.2. Before PHP 6, you can use setlocale () to change the region settings of the system. From PHP 6, you must use the i18n_loc_set_default () function.
Example
The code is as follows:
$ 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 http://www.bkjia.com/PHPjc/324456.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324456.htmlTechArticleasort () definition and usage asort () function sorts arrays and maintains an index relationship. It is mainly used to sort the arrays that are very important to the unit order. Optional second parameter package...