PHP reads the contents of the text file and displays it in pages, _php tutorial

Source: Internet
Author: User

PHP reads the contents of the text file and displays it in pages,


function is simple, just use PHP to read the text (TXT) file and page display

<?php//----------------You should save this file as m.php----------------session_start ();  if (empty ($page)) {$page = 1;} if (Isset ($_get[' page ') ==true) {$page =$_get[' page '];}? >  
 
  
  <title>Read Result</title>    
 
 
<?php if ($page) {$counter =file_get_contents ("example.t XT "); -------read the file into a string.-------$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 <?phpecho "Home"; if ($page!=1) {echo "Prev";} if ($page < $page _count) {echo "next page";} echo "Last";?>

Articles you may be interested in:

    • Code for reading text files under high efficiency PHP
    • AJAX real-time Read input text (PHP)
    • Read efficiency of PHP text files
    • PHP quickly read the package class of CSV large files by line share (also applicable to other oversized text files)
    • PHP read Rich text when the P tag will appear red line is what's going on
    • thinkphp automatic Escape solution for reading errors caused by storing rich text editor content
    • How php reads txt text files and displays them in pagination

http://www.bkjia.com/PHPjc/1087266.html www.bkjia.com true http://www.bkjia.com/PHPjc/1087266.html techarticle PHP Read text file content and page display, the function is very simple, just use PHP read text (TXT) file and page to display PHP//----------------You should save this file as m.php--...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.