loading

Tag cloud font sizer

This generates a font size based on score (the higher the score the higher the size). Useful in making a cloud of tags like a tag cloud or something. Pass an array of tag => score and it will return an array of tag => font size. <?PHP
function makeacloudoutoftagslikeatagcloudorsomething($tags$minfont=10$maxfont=30){
       
$max=max($tags);
      
$min=min($tags);
    foreach(
$tags as $tag => $count){
        
$tags[$tag]=round((($count-$min)*(($maxfont-$minfont)/$max))+$minfont);
    }
    return 
$tags;
}
?>
(1) | by Jove on March 27th, 2008

An account is required to post comments and adaptations

COMMENTS AND ADAPTATIONS

This works really well.

$sizes = makeacloudoutoftagslikeatagcloudorsomething($tags,'8','28');
echo "<p>";
foreach($sizes as $tag => $size){
echo "<a style='font-size:" . $size . "pt' href='browse/tag/" . $tag . "'>" . $tag . "</a>\n";
}
echo "</p>\n";

... nice function name by the way.

(1) | a comment by defproc on March 27th, 2008
Beware of news monopolies. | Powered by: Apache / PHP / MySQL | Made in Ninjapad NX | © defproc.co.uk, 2007_