PHP creates a tag cloud function to generate a series of links with different sizes and looks interesting.
01 <? Php
02 function getCloud ($ data = array (), $ minFontSize = 12, $ maxFontSize = 30)
03 {
04 $ minimumCount = min (array_values ($ data ));
05 $ maximumCount = max (array_values ($ data ));
06 $ spread = $ maximumCount-$ minimumCount;
07 $ cloudHTML = '';
08 $ cloudTags = array ();
09 $ spread = 0 & $ spread = 1;
10 foreach ($ data as $ tag => $ count)
11 {
12 $ size = $ minFontSize + ($ count-$ minimumCount)
13 * ($ maxFontSize-$ minFontSize)/$ spread;
14 $ cloudTags [] ='
16 '\ 'returned a count of'. $ count. '">'
17. htmlspecialchars (stripslashes ($ tag )).'';
18}
19 return join ("\ n", $ cloudTags). "\ n ";
20}
21?>
Call example:
View sourceprint?
1 <? Php
2 $ arr = Array ('codecs' => 35, 'adobe '=> 22, 'background' => 43,
3 'blur' => 18, 'canvas '=> 33, 'class' => 15, 'Design' => 8, 'encoding' => 12, 'encryption' => 30,
4 'effect' => 28, 'filters '=> 42 );
5 echo getCloud ($ arr, 12, 36 );
6?>