function tagcloud($taglist, $num = "") { arsort($taglist); // sort by number of tag instances if ($num) array_splice($taglist, $num); // keep the top $num - kill the rest ksort($taglist); // sort by tag name alphabetically $max = max($taglist); foreach ($taglist as $tag => $number) { echo "$tag\n"; } echo "\n"; }