system paging file. txt

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    system paging file. txt

    I have a book in. txt
    I managed to open it to read it all, but about 40 pages
    I used the following code to open the book:
    PHP Code:
    $file="MyBook.txt";
    $open=fopen($file"r");
    $raed=fread($openfilesize($file));
    echo 
    nl2br ($read); 
    all right, this is very good.
    and now, how to paging page, each 370 words / page?

    sorry for my bad english and thanks for responses

    #2
    use substr() function.
    PHP: substr - Manual
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      Here you go dude i did it for you

      PHP Code:
      <?php
      $file 
      "MyBook.txt";
      $open=fopen($file"r"); 
      $raed=fread($openfilesize($file));

      $page 1;   // change the page number here
      $limit 370// number of words

      $perpage $limit;
      $words explode(" ",$raed);
      $perpage = ($limit*$page sizeof($words)) ? ($perpage $limit $page) : ($perpage sizeof($words));
      for(
      $i=($perpage-$limit); $i<$perpage$i++) echo $words[$i]." ";
      ?>
      Last edited by wap2k; 10.01.10, 15:08.

      Comment

      Working...
      X