Sort Array (Ascending Order), According to Key – ksort()

The following example sorts an associative array in ascending order, according to the key:

<?php
$age = array("Ram"=>"30", "Shyam"=>"27", "Karan"=>"40");
ksort($age);
?>
Scroll to Top