//change from $n = sizeof($this->PageGroups) + 1; //to if (empty($this->PageGroups)) { $n = 1; } else { $n = count($this->PageGroups)+1; }