/**
* 内容分页
* @param text content
* @param int page
* @param string needle 分页标识
*/ function contentPage($content, $needle = '<hr style="page-break-after:always;" class="ke-pagebreak" />') { //根据分页标识来拆分分页 $pageContent = explode($needle, $content); //$_GET['p'] 内容分页的参数 $page = isset($_GET['p']) ? intval($_GET['p']) : 0; $contentNowPage = $page > 0 ? $page - 1 : 0; echo $pageContent[$contentNowPage]; if (($pageCount = count($pageContent)) > 1) { $pageStr = '<div class="clear"></div><div class="page">'; for ($i = 1; $i <= $pageCount; $i++) { $style = ''; if ($page == $i) { $style = 'class="current"'; } $pageStr .= '<a href="?p=' . $i . '" ' . $style . '>' . $i . '</a>'; } $pageStr .= '</div>'; echo $pageStr; } }