作者:然后突然4_944 | 来源:互联网 | 2018-05-16 05:39
就是根据内容字数(比如说10000字)进行分页的组件?
回复内容:
就是根据内容字数(比如说10000字)进行分页的组件?
PHP 没有组件的概念,应该是 library。
可以使用 pagination
做关键词,在 github 搜索:Search pagination On Github
应该是分页class 类,封装成了一个library 类库
建议1,使用类似 [page] 的分割符进行分页:
$cOntent= '123123123123123123123[page]123123123123123';
$page = explode('[page]', $content);
echo $page[0];
建议2,按固定行数行分割:
$cOntent= '123123123123123123123
123123123123123
123123123123123
123123123123123
123123123123123
123123123123123
123123123123123
';
$lines = explode("\n", $content);
//第几页
$page = 1;
//每页显示多少行
$page_size = 2;
//当前页应该显示的行
$current_cOntent= array_slice($lines, ($page-1)*$pagesize, $page_size);
//输出
echo implode("\n", $current_content);
建议3,你想要的按 N 字分页方法:
function mb_str_split($str, $length = 1, $encoding = 'utf-8') {
if ($length <1){
return false;
}
for ($result = array(), $i = 0; $i
PS.以上代码均手写未测试,使用时请自行适当修改