how about stepping back and taking a different approach .. instead of messing with the range before the range is set .. how about adding conditions inside your loop... you would need to make a $max_value variable though.
PHP Code:
$max_value = 250;
$range = range(($page-3), ($page+3));
foreach ($range as $value) {
if(($value > 0) && ($value < ($max_value + 1))){
if ($value == $page) {
echo "[$value] \n";
} else {
echo "<a href=\"{$_SERVER['PHP_SELF']}?page=$value\">$value</a> \n";
}
}
}