system paging file. txt

Started on the old forum in January 2010 · view the original in the archive · old links redirect here

2 replies · 466 views · started 16 years ago · 1 min read

3 participants
whiteboy Junior · 26 posts #1

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:

$file="MyBook.txt";
$open=fopen($file, "r");
$raed=fread($open, filesize($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 🙂

ask me! do not steal! be inventive!

wap2k Developer · 168 posts #3

Here you go dude i did it for you 🙂

<?php
$file = "MyBook.txt";
$open=fopen($file, "r"); 
$raed=fread($open, filesize($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]." ";
?>

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close