Posted by guttyguppy on 09/28/13 11:41
I know that file('mytext.txt'); will return an array of all the lines
of text in mytext.txt. What I want is to grab the text from random line
in mytext.txt.
$lines = file('words.txt');
$random = rand() % 100;
echo "line=" . $lines[$random];
The problem is I have a very long text file, and each time the php page
is loaded there is a delay as it needs to assemble the enormous array.
How can I tell the php page to locate the random line number in
mytext.txt and only load that variable? Thanks for any advice.
[Back to original message]
|