intelliproject logo

Location: Web development - PHP    License: The Intelliproject Open License (IPOL)

Another way to calculate tag cloud sizes

Posted by Panos Kyriakakis

Some time ago i found somewhere i cant remember this tag cloud sizes calculation which gives better results

Skill: Intermediate

Posted: 21/11/2008

Views: 748

Rating: 3.00 /5

Popularity: 1.43

Sign Up to vote for this article

Introduction

Some time ago I wanted to implement a tag cloud in my current project i searched the web for a better calculation for tag sizes and i found this one. It is a bit addopted to my case.

The code

 

The $tags array holds any info needed for each tag and a field named 'counter' which is the number of occurences of the tag. That one is the mandatory and actualy used by this code.  The function adds one more named 'size' which is the size in percentage. Yes the css uses % in font size.

The comments in the code makes it clear, just simple calculations after all.

Conclusion

Nice calculation. Just wanted to share it. I will try to locate the original source again.

License

This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)

About the author

Panos Kyriakakis

Panos started coding on a Sinclair ZX-Spectrum +2 in 1987 or 1988, move to pcs and GW-Basic then to CA-Clipper, fortran, pascal, c, VB4, VB5, VB6, asp and landed to PHP about 5 years ago.
Those 20 years many small and big project were build.
These day he tries to polish and give to public an accounting service for small bussines in Greece. It is in beta version and sales force is setting up.

Published a couple open source libs and try to maintain my site.

Location: Greece
Ocupation: Programmer
Home page: http://www.salix.gr

Posted by xsist10 at 22/11/2008 07:15
You can save a few lines by using the min and max function (which support arrays).

$max_qty = max($tags[$i]['counter']);
$min_qty = min($tags[$i]['counter']);

Sign up to post message on the article message board!