Sorting associative arrays can be done in one of several ways:
Sorting an Associative Array (sort_a.php)<pre> <?php $a = array('one' => 'I', 'two' => 'II', 'three' => 'III', 'four' => 'IV'); ksort($a); print_r($a); asort($a); print_r($a); ?> </pre> The preceding code shows these functions in action; Figure 2.3 shows the result. Figure 2.3. Sorting associative arrays.
|