It is array:
$a = rand(1,100);
$b = rand(1,100);
$c = rand(1,100);
$arr = array($a ,$b , $c);
I want to sort generated numbers high to low.
It is array:
$a = rand(1,100);
$b = rand(1,100);
$c = rand(1,100);
$arr = array($a ,$b , $c);
I want to sort generated numbers high to low.
Sort Array (Descending Order), According to Value - arsort()
<!DOCTYPE html>
<html>
<body>
<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
arsort($age);
foreach($age as $x => $x_value) {
echo "Key=" . $x . ", Value=" . $x_value;
echo "<br>";
}
?>
</body>
</html>
Output:
Key=Joe, Value=43
Key=Ben, Value=37
Key=Peter, Value=35
Use arsort(): reference
print_r(arsort($arr));
Sort an associative array in descending order, according to the value: