asort( ) function sorts array by its values while preserving the keys : asort « Data Structure « PHP






asort( ) function sorts array by its values while preserving the keys

 
//bool arsort ( array &arr [, int options] )
<?
    $capitalcities['England'] = 'London';
    $capitalcities['Wales'] = 'Cardiff';
    $capitalcities['Scotland'] = 'Edinburgh';
    asort($capitalcities);
    // sorted by value, so Cardiff, Edinburgh, London
?>
  
  








Related examples in the same category

1.After using asort()to return the array's elements to their original order
2.asort() Constants
3.asort() function works in the same way as sort() and preserves the array's original key/value associations.
4.asort() function: array indexes maintain their original association with the elements.
5.Sorting with asort()