asort() and arsort() work like sort() and rsort(), but they preserve the association between each element's key and its value:
<?php $myBook = array("title"=> "PHP", "author"=> "D", "year"=> 2018); asort($myBook);/*from w ww .j a v a2 s. c om*/ print_r($myBook); arsort($myBook); print_r($myBook); ?>