PHP read txt text file and display the method of pagination,
The example in this article describes how PHP reads txt text files and displays them in pagination. Share to everyone for your reference. The implementation method is as follows:
Copy the Code code as follows: <?php
Session_Start ();
if (empty ($page)) {$page = 1;}
if (Isset ($_get[' page ') ==true) {$page =$_get[' page '];}
?>
Read Result
<?php if ($page) { $counter =file_get_contents ("Example.txt"); Read TXT file contents to $counter $length =strlen ($counter); $page _count=ceil ($length/5000); function Msubstr ($str, $start, $len) { $strlength = $start + $len; $tmpstr = ""; for ($i =0; $i < $strlength; $i + +) { if (Ord (substr ($str, $i, 1)) ==0x0a) { $tmpstr. = ' '; } if (Ord (substr ($str, $i, 1)) >0xa0) { $tmpstr. =substr ($str, $i, 2); $i + +; } else{ $tmpstr. =substr ($str, $i, 1); } } return $tmpstr; } ------------Intercept Chinese strings--------- $c =msubstr ($counter, 0, ($page-1) *5000); $c 1=msubstr ($counter, 0, $page *5000); Echo substr ($c 1,strlen ($c), strlen ($c 1)-strlen ($c)); }?>
|
<?php echo $page;? >/<?php echo $page _count;? > Page |
<?php echo "Home"; if ($page!=1) { echo "Prev"; } if ($page < $page _count) { echo "Next page"; } echo "Last"; ?>
|
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/966547.html www.bkjia.com true http://www.bkjia.com/PHPjc/966547.html techarticle PHP Read txt text file and pagination display method, this article describes the PHP read txt text file and pagination display method. Share to everyone for your reference. The concrete implementation method is as follows: ...