The best resources for developers

How do I generate a tag cloud from an array using h1 through h6 for sizing?

$artist = array("the roots","michael jackson","billy idol","more","and more","and_YET_MORE");
$count = array(5,3,9,1,1,3);
$highest = max($count);
for (int $x = 0; $x < count($artist); $x++)
    $normalized = $count[$x] / $highest;
    $heading = ceil($normalized * 6); // 6 heading types
    echo "<h".$heading.">".$artist[$x]."</h".$heading.">";

Tags: php arrays tag-cloud

Source: By w-ll as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 3.0

Related code-snippets: