建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > PHP学习 > php怎么创建运标签

php怎么创建运标签

时间:2015-03-03 17:13:35  来源:免费模板网 作者:风雪 阅读次数 tags云标签php运用


之前流行的云标签,在php里面怎么实现呢?

把样式设置好会更加美观一点


实现代码如下:

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[] = '<a style="font-size: ' . floor( $size ) . 'px' 
. '" href="#" title="\'' . $tag . 
'\' returned a count of ' . $count . '">' 
. htmlspecialchars( stripslashes( $tag ) ) . '</a>'; 


return join( "\n", $cloudTags ) . "\n"; 

/************************** 
**** Sample usage ***/ 
$arr = Array('Actionscript' => 35, 'Adobe' => 22, 'Array' => 44, 'Background' => 43, 
'Blur' => 18, 'Canvas' => 33, 'Class' => 15, 'Color Palette' => 11, 'Crop' => 42, 
'Delimiter' => 13, 'Depth' => 34, 'Design' => 8, 'Encode' => 12, 'Encryption' => 30, 
'Extract' => 28, 'Filters' => 42); 
echo getCloud($arr, 12, 36); 

本文地址:https://www.freemoban.com/php/2015/0303/785.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!