Php Array Elements Sort Function
What is sort Function?
Explanation
The "sort" function sorts elements of an array.
Syntax:
sort(array,sort type)
In the above syntax "array" is the array to be sorted. The "sort type" specifies the type in which the elements to be sorted, for example "SORT_REGULAR",is the default type, "SORT_NUMERIC", treat values numerically, "SORT_STRING", treat values as strings, "SORT_LOCALE_STRING", treat values as string based on local setting.
Example :
<?php
$b=array("a"=>"Grapes","b"=>"Apple","c" =>"Cherry");
sort($b);
print_r($b);
?>
Result :
[0] => Apple
[1] => Cherry
[2] => Grapes
In the above example the array "$b" is sorted, displays the elements value starting from "Apple".