PHP Tag Cloud composer package Implementation of

dev-master 2014-07-11 15:40 UTC

This package is not auto-updated.

Last update: 2024-05-21 02:21:06 UTC


PHP Tag Cloud composer package Implementation of

PHP Tag Cloud


Basic usage

$cloud = new TagCloud();
echo $cloud->render();

Convert a string

$cloud->addString("This is a tag-cloud script, written by Del Harvey. I wrote this tag-cloud class because I just love writing code.");

Adding multiple tags


Removing a tag


Removing multiple tags


More complex adding

$cloud->addTag(array('tag' => 'php', 'url' => '', 'colour' => 1));
$cloud->addTag(array('tag' => 'ajax', 'url' => '', 'colour' => 2));
$cloud->addTag(array('tag' => 'css', 'url' => '', 'colour' => 3));

Set the minimum length required


Limiting the output


Set the order


Set a custom HTML output

$cloud->setHtmlizeTagFunction( function($tag, $size) {
	$link = '<a href="'.$tag['url'].'">'.$tag['tag'].'</a>';
	return "<span class='tag size{$size} colour-{$tag['colour']}'>{$link}</span> ";

Outputting the cloud (shown above)

echo $cloud->render();

More usages on in a prettier format can be found here:


To run the unit test suite:

cd tests
curl -s | php
php composer.phar install
./vendor/bin/phpunit lotsofcode/TagCloud/TagCloud.php

Submitting pull requests

Indentation style, size and encoding should be followed as per .editorconfig settings.