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 "<span style=\"font-size:"; echo 100+ceil((($number-min($taglist)) / ($max-min($taglist))) * 10)*10; echo "%\"><a href=\"tag/" . $tag . "\" title=\"$number people have tagged this\">$tag</a></span>\n"; } echo "\n";}