$page = !empty( $_GET['page'] ) ? (int) $_GET['page'] : 1;
$total = count( $yourDataArray ); //total items in array
$limit = 10; //per page
$totalPages = ceil( $total/ $limit ); //calculate total pages
$page = max($page, 1); //get 1 page when $_GET['page'] <= 0
$page = min($page, $totalPages); //get last page when $_GET['page'] > $totalPages
$offset = ($page - 1) * $limit;
if( $offset < 0 ) $offset = 0;
$yourDataArray = array_slice( $yourDataArray, $offset, $limit );
echo 'Pages: ';
for($i = 1; $i <= $totalPages; $i++){
if($i == $page){
echo '<b>' . $i . '</b> ';
}elseif($i != $page){
echo '<a href="testpage.php?page=' . $i . '">' . $i . '</a> ';
}
}
Refer: http://stackoverflow.com/questions/26451362/how-to-add-php-pagination-in-arrays
Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
ReplyDeleteJava Training in Pune
BPO Solutions is a Pakistani based, RPO & BPO Company.
ReplyDeletehttps://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
RL7OLA
Great article! Very helpful for readers looking for clear insights. For those interested in skill development, check out best training institute in Chennai offering quality courses. Helpful information about best guest posting sites.
ReplyDelete