if the variable $page value от 1 до 5 - you need to get 1 on the output

if in a variable $page value от 5 до 10 - you need to get 2 on the output

if the $page variable has a value от 10 до 15 , you need to get 3 on the output

and so on

How can this be implemented? nothing came to mind = /. thank!

    1 answer 1

    It is necessary to use rounding up:

     $size = 5; foreach (range(1, 15) as $count) { $page = ceil($count / $size); $rest = ($count % $size) ?: $size; echo "Для \$count=$count, \$page=$page, \$rest=$rest\n"; }