用layui,就是弄个简单的页面。大佬帮我看看这个分页是哪里出错了,layui前端分不了页
[PHP] 纯文本查看 复制代码 $str= file_get_contents("./stat/20201128.log");//将文件中的内容读成字符串
$str1=explode("\n",$str);//按换行进行拆分//单引号是转义字符,所以必须使用双引号
$data = [];
$count = count($data);
$page = $_GET['page'];
$limit = $_GET['limit'];
$firstIndex=($page-1)*$limit;
$new = array_slice($data,$firstIndex,$limit);
foreach($str1 as $value){
$val = json_decode($value,true);
$data[] = [
'time'=>$val['time'],
'ip'=>$val['ip'],
'user_agent'=>$val['user_agent'],
'url'=>$val['url'],
'query'=>$val['query'],
'city'=>$val['city'],
];
}
$response_list=[
'code'=>'0',
'msg'=>'',
'count'=>$count,
'data'=>$data
];
//print_r($response_list);
echo json_encode($response_list); |