PHP asort() function
Mga halimbawa
Tatalaga ng pagtatalaga ng puno ng kailangan para sa talaan ng asosasyon sa pagtaas ng talaan:
<?php $age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31"); asort($age); ?>
Pangangatwiran at paggamit
Ang function na asort() ay nagtatalaga ng pagtatalaga ng talaan ng kailangan para sa pagtatalaga ng puno ng kailangan sa talaan ng asosasyon sa pagtaas ng talaan.
Tips:Please use arsort() The function sorts an associative array in descending order by key value.
Tips:Please use ksort() The function sorts an associative array in ascending order by key name.
Syntax
asort(array,sortingtype);
Parameters | Description |
---|---|
array | Required. Specifies the array to be sorted. |
sortingtype |
Optional. Specifies how to sort the elements/items of the array. Possible values:
|
Description
The asort() function sorts an array while maintaining the index relationship. It is mainly used to sort combined arrays where the order of the units is very important.
The optional second parameter includes additional sorting identifiers.
Returns TRUE if successful, otherwise FALSE.
Technical Details
Return Value: | Returns TRUE if successful, otherwise FALSE. |
PHP Version: | 4+ |