وظيفة asort() في PHP
مثال
ترتيب مصفوفة مرتبطة وفقًا للقيمة المفتاحية:
<?php $age=array("Bill"=>"60","Steve"=>"56","Mark"=>"31"); asort($age); ؟>
التعريف والاستخدام
وظيفة asort() تقوم بترتيب مصفوفة مرتبطة وفقًا للقيمة المفتاحية.
Tip:Please use arsort() The function sorts the associated array in descending order by key value.
Tip:Please use ksort() The function sorts the associated 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 the elements/items of the array are sorted. 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 elements is very important.
The optional second parameter contains additional sorting identifiers.
Returns TRUE if successful, FALSE otherwise.
Technical Details
Return Value: | Returns TRUE if successful, FALSE otherwise. |
PHP Version: | 4+ |