<?php class Pager { public $Redirect=False; 'Next' => False); private $DisplayPerPage=15; private $CurrentPage=0; private $Marker='page'; private $PagesAmount=0; public function __construct($DisplayPerPage=Null, $Marker=Null) { $this->DisplayPerPage=$DisplayPerPage; else $this->Error('Class Pager needs integer value in first argument.', True); $this->Marker=$Marker; else $this->Error('Class Pager needs string or integer value in third argument.', True); $this->GetCurrentPage(); } public function ReturnPart($Data) { $this->Assign($Data); if($this->CurrentPage<=$this->PagesAmount && $this->CurrentPage>=0) { $FirstElement=$this->CurrentPage*$this->DisplayPerPage; $LastElement=$FirstElement+$this->DisplayPerPage-1; $Counter=0; foreach($this->Data as $Key => $Value) { if($Counter>=$FirstElement && $Counter<=$LastElement) $this->Package[$Key]=$Value; $Counter++; } return $this->Package; } else if($this->Redirect==True) hreader('Location: '.$this->Redirect); else $this->Error('Page '.$this->CurrentPage.' doesn't exists.'); } private function Assign($Data) { if(is_array($Data)) $this->Data=$Data; else $this->PagesAmount=ceil(count($Data)/$this->DisplayPerPage)-1; $this->Allowing(); } private function GetCurrentPage() { if(is_numeric($_GET[$this->Marker])) $this->CurrentPage=$_GET[$this->Marker]; else $this->CurrentPage=0; } private function Allowing() { if($this->CurrentPage>0 && $this->CurrentPage<=$this->PagesAmount) $this->Allowed['Previous']=True; if($this->CurrentPage>=0 && $this->CurrentPage<$this->PagesAmount) } private function Error($Communicate, $Die=False) { if($Die==True) die('<code>'.$Communicate.'</code>'); else echo('<code>'.$Communicate.'</code>'); } } ?>
Jak widać dokumentacja jest obszerna

Sposób użycia:
<?php include('pager.class.php'); $Pager=new Pager(); $Array=$_SERVER; $Part=$Pager->ReturnPart($Array); ?>