search
Homephp教程php手册PHP创建标签云函数

PHP创建标签云函数

Jun 13, 2016 am 09:35 AM
phpcloudfunctioncreateBundleEffectLabelgenerateLink

   PHP创建标签云函数,把标签生成一系列链接效果,并大小不一,看上去有意思。

  01

  02function 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;

  10foreach( $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}

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

  20}

  21?>

  调用例子:

  view sourceprint?

     1

  2$arr = Array('CodeFans' => 35, 'Adobe' => 22, 'Background' => 43,

  3'Blur' => 18, 'Canvas' => 33, 'Class' => 15, 'Design' => 8, 'Encode' => 12, 'Encryption' => 30,

  4'Extract' => 28, 'Filters' => 42);

  5echo getCloud($arr, 12, 36);

  6?>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools