<?php // Prepare current, total pages and pagination container $current = isset($_GET['page']) ? intval($_GET['page']) : 1; $total = 5; $pagination = []; // Check if pagination required if ($total > 1) { // Check if current page is not first page if ($current > 1) { $pagination[] = '<a class="pagination_backward" href="#">قبلی</a>'; $pagination[] = '<span style="color:#848d95; margin:0px 10px;">…</span>'; } // Iterate through pages for ($i = 1; $i <= $total; $i++) { // Check if handling current page if ($i === $current) { $pagination[] = '<a class="pagination_active" href="#">' . $i . '</a>'; } else { $pagination[] = '<a href="#">' . $i . '</a>'; } } // Check if current page is not last page if ($current < $total) { $pagination[] = '<span style="color:#848d95; margin:0px 10px;">…</span>'; $pagination[] = '<a class="pagination_backward" href="#">بعدی</a>'; } } var_dump($pagination);
You have javascript disabled. You will not be able to edit any code.