Php sorting function of an array:
	-  sort()  -This will sort an arrays in ascending order.
 
	-  rsort() -This will sort arrays in descending order
 
	-  asort() -This function will sort associative arrays in ascending order, according to the value.
 
	-  ksort() -By using the associative arrays it will sort in ascending order,according to a key.
 
For Example:
<?php
$val=array("rose","lotus","marigold");
sort($val);
$age =array("mohan"=>"30", "ram"=>"35", "sohan"=>"40");
asort($age);
$length = count($cars);
for($x=0; $x<=lenght; $x++)
{
     echo $val[$x];
     echo "<br>";
}
foreach($age as $x => $x_value)
{
   echo "key=" . $x . ", Value=" . $x_value;
   echo "<br>";
}
?>
This will sort an array in ascending order according to the values  passes to it.
                       
                    
0 Comment(s)