Of course, you will have to read in the file first, preferably in an array.
To read a file in an array, you just need the file() function:
$lines = file('quotes.txt');
Then, you shuffle the array with shuffle() function that randomizes all the items in the array thus shuffling the lines in the file quotes.txt:
$lines = shuffle($lines);
Doesn’t work for me, I have 6,000,000 lines in my text file 🙁
Out of memory, uses more than 500MB
03 Feb 2010
Woah, what is it.
You have an error in the code. instead of:
$lines = shuffle($lines);
use only
shuffle($lines);