Sorting PHP Arrays

 

<?PHP

$full_name = array();

$full_name["Roger"] = "Waters";
$full_name["Richard"] = "Wright";
$full_name["Nick"] = "Mason";
$full_name["David"] = "Gilmour";

foreach ($full_name as $first_name => $surname) {

print "Key = " . $first_name . " Value = " . $surname . "<BR>";

}

print "<P>";

ksort($full_name);

foreach ($full_name as $first_name => $surname) {

print "Key = " . $first_name . " Value = " . $surname . "<BR>";

}

?>