<?php
$nums = array(15, 2.2, -4, 2.3, 0);
asort($nums);
printf("
%s\n", var_export($nums, TRUE));
ksort($nums);
printf("
%s\n", var_export($nums, TRUE));
?>
Here is another tutorial using krsort to sort an associative array
<?php
$dogs = array('Lassie' => 'Collie', 'Bud' => 'Sheepdog', 'Rin-Tin-Tin' => 'Alsatian', 'Snoopy' => 'Beagle');
krsort($dogs);
printf("<pre>%s</pre>\n", var_export($dogs, TRUE));
?>
Here is a tutorial about shuffling arrays
<?php
$nums = array(15, 2.2, -4, 17, 2.9, 0, 14);
shuffle($nums); //shuffles the array in random order
printf("<pre>%s</pre>\n", var_export($nums, TRUE));
shuffle($nums);
printf("<pre>%s</pre>\n", var_export($nums, TRUE));
shuffle($<
%s<\n", var_export($nums, TRUE));
?>
No comments:
Post a Comment