This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Arrays

asort() Function

Key=Peter, Value=35
Key=Ben, Value=37
Key=Joe, Value=43

<?php
// associative array to sort in ascending values
$age=array("Peter"=>"35","Ben"=>"37","Joe"=>"43");

// sort $age array
asort($age);

// display the results
foreach($age as $x=>$x_value)
   {
   echo "Key=" . $x . ", Value=" . $x_value;
   echo "<br>";
   }
?>