PHP 創(chuàng)建標簽云函數(shù)代碼
更新時間:2010年05月26日 00:14:15 作者:
PHP創(chuàng)建標簽云函數(shù)代碼,使用此函數(shù)創(chuàng)建標簽云。
復制代碼 代碼如下:
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);
這里是摘自腳本之家之前發(fā)布的文章。更多的技巧可以參考。
收集的二十一個實用便利的PHP函數(shù)代碼
您可能感興趣的文章:
相關(guān)文章
簡單談談PHP中的include、include_once、require以及require_once語句
include() 、require()語句包含并運行指定文件。這兩結(jié)構(gòu)在包含文件上完全一樣,唯一的區(qū)別是對于錯誤的處理。require()語句在遇到包含文件不存在,或是出錯的時候,就停止即行,并報錯。include()則繼續(xù)即行。2016-04-04EarthLiveSharp中cloudinary的CDN圖片緩存自動清理python腳本
這篇文章主要介紹了EarthLiveSharp暫時沒有清理cloudinary的CDN圖片緩存的功能,于是我用python寫了一個,并嘗試用gist管理,需要的朋友可以參考下2017-04-04