成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

PHP創建標簽云的函數(源代碼)

2010-08-28 10:56:04來源:西部e網作者:

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);

關鍵詞:PHP

贊助商鏈接:

主站蜘蛛池模板: 长阳| 佛山市| 日喀则市| 宝山区| 合山市| 洛浦县| 德格县| 华坪县| 四会市| 阿城市| 房产| 石林| 余姚市| 阿荣旗| 淮滨县| 抚松县| 五莲县| 成安县| 武鸣县| 大冶市| 修水县| 巢湖市| 尼勒克县| 沧州市| 九江县| 盐城市| 哈尔滨市| 莫力| 永安市| 垣曲县| 张家川| 茶陵县| 桦甸市| 铜川市| 龙口市| 大埔区| 玉屏| 苏尼特右旗| 江北区| 敖汉旗| 成安县|