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.">";
}
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:
- How do I unload byteArray with ActionScript3?
- How do you enable a plugin for a PHP application?
- Flat file databases are generally stored in a computer hard drive. Flat file databases cannot be shared by any party with another.
- Is Object Property accessible from within object method?
- How can you track a downloaded file?
- Is PHP session security really that important for web?
- What are the best ways to access Exchange using PHP?
- How do you keep your email address and password private while you are surfing the net?
- Redefining an attribute in Python with an index in array of objects using 'in'. If no object is found in an array of objects then it is not correct.
- Why does PHP Variable pass by value when it should be passed by reference?
- How do I debug a PHP script?
- Make Apache / XAMPP serve file outside of htdocs folder. Make XAMPP and Apache serve file outside of htdocs folder.
- How do I get authenticated user ID under Apache using PHP & HTTP Authentication?
- A method property uses an object property as default, so a method property is not used as a method property.
- What are some ways to get matches using preg_replace in PHP?