- array_slice: documentation ( source)
- implode: documentation ( source)
- range: documentation ( source)
<?php
$pages = range(1,100);
$page = 1;
If($page ==1){
$n = 0;
}else{
$n = 1;
}
Echo implode(" ", array_slice($pages, $page-1-$n, 5)) . " . . . . " . Implode(" ", array_slice($pages, -3));