PHP创建WEB2.0形式的标签云tag cloud 简单例子
1. < ?php
2. function tag_cloud($tags) {
3. $maxsize = 40;
4. $minsize = 20;
5.
6. $maxval = max(array_values($tags));
7. $minval = min(array_values($tags));
8.
9. $spread = $maxval - $minval;
10.
11. $step = ($maxsize - $minsize) / ($spread);
12.
13. foreach ($tags as $key => $value) {
14. $size = round($minsize + (($value – $minval) * $step));
15. echo ‘‘.$key.’ ‘;
16. }
17. }
18.
19. $tags = array(‘php’=>30, ‘javascript’=>24, ‘java’=>17, ‘python’=>26, ‘ruby’=>17);
20.
21. tag_cloud($tags);


