ciao
ho una funzione tramite la quale mostrare dei tag a rotazione, il problema è che li mostra tutti, come posso limitare il numero?

Codice PHP:
<?php      class wordCloud    {      var $version '1.0';        var $wordsArray = array();                                  function __construct($words false)        {            if ($words !== false && is_array($words))            {                foreach ($words as $key => $value)                {                    $this->addWord($value);                }            }        }                              function wordCloud($words false)        {            $this->__construct($words);        }                                  function addWord($word$value 1)        {            $word strtolower($word);            if (array_key_exists($word$this->wordsArray))                $this->wordsArray[$word] += $value;            else                $this->wordsArray[$word] = $value;                         return $this->wordsArray[$word];        }                         function shuffleCloud()        {            $keys array_keys($this->wordsArray);                         shuffle($keys);                         if (count($keys) && is_array($keys))            {                $tmpArray $this->wordsArray;                $this->wordsArray = array();                foreach ($keys as $key => $value)                    $this->wordsArray[$value] = $tmpArray[$value];            }        }                                  function getCloudSize()        {            return array_sum($this->wordsArray);        }                                  function getClassFromPercent($percent)        {            if ($percent >= 99)                $class 1;            else if ($percent >= 70)                $class 2;            else if ($percent >= 60)                $class 3;            else if ($percent >= 50)                $class 4;            else if ($percent >= 40)                $class 5;            else if ($percent >= 30)                $class 6;            else if ($percent >= 20)                $class 7;            else if ($percent >= 10)                $class 8;            else if ($percent >= 5)                $class 9;            else                $class 0;                         return $class;        }                                  function showCloud($returnType "html")        {            $this->shuffleCloud();            $this->max max($this->wordsArray);            if (is_array($this->wordsArray))            {                $return = ($returnType == "html" "" : ($returnType == "array" ? array() : ""));                foreach ($this->wordsArray as $word => $popularity)                {                    $sizeRange $this->getClassFromPercent(($popularity $this->max) * 100);                    if ($returnType == "array")                    {                        $return[$word]['word'] = $word;                        $return[$word]['sizeRange'] = $sizeRange;                    }                    else if ($returnType == "html")                    {                        $return .= "<span class='word size{$sizeRange}'>  {$word}  </span>";                    }                }                return $return;            }        }    }  ?>