The built-in PHP asort() function is used for sorting an array in such a way that the array indices maintain their correlation with array elements associated with them. This built-in function is mainly used when sorting the associative arrays where the actual order of the element is significant.
asort( $array [, $sort_flags] );
|Sr.No||Parameter & Description|
Required. Specifies an array.
Optional. Specifies how to sort the array values. Possible values −
<?php $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana" ); asort($fruits); print_r($fruits); ?>
Array ( [b] => banana [d] => lemon [a] => orange )
Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.