Sorting with asort()
<?
$meal = array('breakfast' => 'A',
'lunch' => 'B',
'snack' => 'C',
'dinner' => 'D');
print "Before Sorting:\n";
foreach ($meal as $key => $value) {
print " \$meal: $key $value\n";
}
asort($meal);
print "After Sorting:\n";
foreach ($meal as $key => $value) {
print " \$meal: $key $value\n";
}
?>
Related examples in the same category