function page_navigator($begin, $end, $currentpage, $spread = 4) { $ret = array(); $i = $begin; $end++; for (; $i < min($end, $begin + $spread); $i++) $ret[] = $i; if ($i < ($end - $spread) && $i < ($currentpage - ($spread / 2))) $ret[] = '...'; for ($i = max($currentpage - (int)($spread / 2), $i); $i < min($end - $spread, $currentpage + (int)($spread / 2) + 1); $i++) { $ret[] = $i; } if ($i < ($end - $spread)) { $ret[] = '...'; } for ($i = max($i, $end - $spread); $i < $end; $i++) $ret[] = $i; return $ret; }