توابع arsort() در PHP
مثال
ترتیب کاهشی آرایه مرتبط بر اساس کلیدها انجام میشود:
<?php $age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31"); arsort($age); ?>
تعریف و استفاده
arsort() 함수 به ترتیب کاهشی بر اساس کلیدها در آرایه مرتبط مرتب میکند.
Tips:Please use asort() The function sorts the associated array in ascending order by key value.
Tips:Please use krsort() The function sorts the associated array in descending order by key name.
Syntax
arsort(array,sortingtype);
Parameters | Description |
---|---|
array | Required. Specify the array to be sorted. |
sortingtype |
Optional. Specify how to sort the elements/items of the array. Possible values:
|
Description
The arsort() function sorts an array in reverse order while maintaining the index relationship. It is mainly used to sort combined arrays where the order of the elements is very important.
The optional second parameter contains additional sorting identifiers.
Returns TRUE if successful, otherwise returns FALSE.
Technical Details
Return Value: | Returns TRUE if successful, otherwise returns FALSE. |
PHP Version: | 4+ |