PHP creates a tag cloud function code. use this function to create a tag cloud.
The code is as follows:
Function getCloud ($ data = array (), $ minFontSize = 12, $ maxFontSize = 30)
{
$ MinimumCount = min (array_values ($ data ));
$ MaximumCount = max (array_values ($ data ));
$ Spread = $ maximumCount-$ minimumCount;
$ CloudHTML = '';
$ CloudTags = array ();
$ Spread = 0 & $ spread = 1;
Foreach ($ data as $ tag => $ count)
{
$ Size = $ minFontSize + ($ count-$ minimumCount)
* ($ MaxFontSize-$ minFontSize)/$ spread;
$ CloudTags [] = '.' "href =" # "title =" \ ''. $ tag.
'\ 'Returned a count of'. $ count. '">'
. Htmlspecialchars (stripslashes ($ tag )).'';
}
Return join ("\ n", $ cloudTags). "\ n ";
}
/**************************
* *** Sample usage ***/
$ Arr = Array ('actionscript '=> 35, 'Adobe' => 22, 'array' => 44, 'background' => 43,
'Blur' => 18, 'canvas '=> 33, 'class' => 15, 'color paster' => 11, 'crop' => 42,
'Delimiter' => 13, 'dest' => 34, 'design' => 8, 'encode' => 12, 'encryption' => 30,
'Effect' => 28, 'Filters '=> 42 );
Echo getCloud ($ arr, 12, 36 );
This is an excerpt from an article published before the home of scripts. For more tips, refer.
Collected 21 practical and convenient PHP function code