Home  >  Article  >  Backend Development  >  Number of page numbers for circular paging

Number of page numbers for circular paging

巴扎黑
巴扎黑Original
2016-11-22 16:20:351246browse

$page = 1;

$total = 20;

 

$prevs = $page - 4;

if($prevs <= 0) {

$prevs = 1;

}

$next = $page + 4;

if($next > $total) {

$next = $total;

}

for($i = $prevs; $i <= $page - 1; $i++) {

echo $i."rn";

}

echo '['.$page.']'."rn";

for($i = $page + 1; $i <= $next; $i++) {

echo $i."rn";

}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn