Λειτουργία arsort() PHP
Παράδειγμα
Αποσύρτηση της σειράς των κλειδιών ενός συνδυασμένου πίνακα σε φθίνουσα σειρά:
<?php $age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31"); arsort($age); ?>
Ορισμός και χρήση
arsort() λειτουργία ορίζει και χρησιμοποιείται για την αποσύρτηση της σειράς των κλειδιών ενός συνδυασμένου πίνακα σε φθίνουσα σειρά.
Tip:Use asort() The function sorts an associative array in ascending order by key value.
Tip:Use krsort() The function sorts an associative array in descending order by key name.
Syntax
arsort(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 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 units is very important.
The optional second parameter contains additional sorting identifiers.
Returns TRUE on success, otherwise FALSE.
Technical Details
Return Value: | Returns TRUE on success, FALSE on failure. |
PHP Version: | 4+ |