What's the most effective means to create a tag cloud from an array making use of h1 via h6 for sizing?

I have the adhering to arrays:

$artist = array("the roots", "michael jackson", "billy idol", "more", "and more", "and_YET_MORE");
$count = array(5, 3, 9, 1, 1, 3);
.

I intend to create a tag cloud that will certainly have musicians with a greater number in $count confined in h6 tags and also the most affordable encased h1 tags.

0
2019-05-03 18:38:47
Source Share
Answers: 3

Perhaps this is a little scholastic and also off subject yet hX tags are possibly not the most effective selection for a tag cloud for factors of record framework and also all that type of point.

Possibly spans or an ol with ideal class features (plus some CSS)?

0
2019-05-08 13:53:15
Source

@Ryan

That's proper yet it in fact makes the tags with the least number, bigger. This code has actually been examined :

$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 ($x = 0; $x < count($artist); $x++) {
    $normalized =  ($highest - $count[$x]+1) / $highest;
    $heading = ceil($normalized * 6); // 6 heading types
    echo "<h$heading>{$artist[$x]}</h$heading>";
}
0
2019-05-07 17:38:17
Source

Off the top of my head ...

$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.">";
}
0
2019-05-07 16:33:53
Source