array_slice function we will use for array pagination to get some part of array
$items = array(1,2,3,4,5,6,7,8,9,10);
$limit = 3;
$qty_items = count($items);
$qty_pages = ceil($qty_items / $limit);
$curr_page = isset($_GET[‘page’]) ? $_GET[‘page’] : 1;
$next_page = $curr_page < $qty_pages ? $curr_page + 1 : null;
$prev_page = $curr_page > 1 ? $curr_page – 1 : null;
$offset = ($curr_page – 1) * $limit;
$items = array_slice($items, $offset, $limit);
$items // Array of elements
$offset // how many elements leave at the time of fetching
$limit //get number of elements from array
Pagination code
for($i = 1; $i <= $qty_pages; $i++){
echo $i;
}
ceil() function return integer number.