1 ) { // get the total number of links $totalPages = count($links["text"]); // set showstart and showend to false $showStart = false; $showEnd = false; // if the total number of pages is greater than 10 if ( $totalPages > 10 ) { // if the current page is less than 5 from the start if ( $currentPage <= 5 ) { // set the minimum and maximum pages to show $minimum = 0; $maximum = 9; $showEnd = true; } // if the current page is less than 5 from the end if ( $currentPage >= ( $totalPages - 5 ) ) { // set the minumum and maximum pages to show $minimum = $totalPages - 9; $maximum = $totalPages; $showStart = true; } // if the current page is somewhere in the middle if ( $currentPage > 5 && $currentPage < ( $totalPages - 5 ) ) { $showEnd = true; $showStart = true; $minimum = $currentPage - 4; $maximum = $currentPage + 4; } } else { $minimum = 0; $maximum = $totalPages; } // print the start of the list $return .= "\n\n\n\n"; } return $return; } ?>