Here we will see How many array sorting functions are present in PHP 5 and how to sort an array in PHP 5. Sorting in php by asort, arsort and array_multisort.

In PHP Language we have many types of functions to sorting the array. We can use these sorting functions when we want to display the array in ascending or descending order. These sorting functions make our task very easier.So here Some of the important array sorting functions are:

a> asort :

This Function Sort an associative array in ascending order, according to the value.

example:-

OUTPUT :

b> array_multisort :

1: array_multisort used to sort multidimensional arrays or multiple array at a time .

2 :While ordering the array it maintains the key if the keys are string ie. Associative array ,but it reindxes the numeric keys.

3 : It returns Boolean value. True on success and false on failure.

example:-

OUTPUT:-

C>arsort:

The arsort() function sorts an associative array in descending order, according to the value.

example:-

OUTPUT:-

 

You can see our PHP Tutorial for fresher and experience developer: 

<<<<< PHP interview questions and answers for fresher and experience 

<<<<< PHP tutorial for beginner Day 4 –  Echo and Print operation in PHP

<<<<< PHP tutorial for beginner Day 3 –  variable scope and type of variable

<<<<< PHP tutorial for beginner Day 2 – Syntax overview and tag

<<<<< PHP tutorial for beginner Day 1 – Introduction and Installation.