search
Homephp教程php手册php简单实现数组分页的方法,php数组分页

php简单实现数组分页的方法,php数组分页

本文实例讲述了php简单实现数组分页的方法。分享给大家供大家参考,具体如下:

首先学东西  要多看手册
用php自带的函数  可以解决一些难解的问题

<&#63;php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 13-6-11
 * Time: 上午11:43
 * To change this template use File | Settings | File Templates.
 */
header("Content-type:text/html;charset=utf-8");
$array =array (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,25);
$page=$_GET['page']&#63;(int)$_GET['page']:'0';
$size=5;
$pnum = ceil(count($array) / $size);
$newArray = array_slice($array,($page-1)*$size,$size);
foreach($newArray as $key=>$val)
{
  echo "<a href=\"array1.php&#63;catid=$key.html\" target=\"_blank\">$val</a>\n";
}
echo "<br/><br/><br/><br/>";
echo "<a href=&#63;>第一页</a>\n";
$str='';
for($i=1;$i<=$pnum-1;$i++)
{
  echo "<a href=\"&#63;page=$i\" target=\"_blank\"";
  if($i==$page){echo "style='color:red;'";};
  echo ">$i</a>\n\n";
}
echo "<a href=&#63;page=$pnum>最后一页</a>\n";
&#63;>

更多关于PHP相关内容感兴趣的读者可查看本站专题:《PHP数组(Array)操作技巧大全》、《php正则表达式用法总结》、《PHP+ajax技巧与应用小结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php操作office文档技巧总结(包括word,excel,access,ppt)》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools