I thought my site was missing something, perhaps a little bit of dynamic text , so now we have it ! Below my logo random one liner quotes will appear
I found the basics at totallyphp but it only read the quotes from an array, not a file, so: I added the file function & turned the script into a function
If you too want simple random quotes to include the source is here. The usage is simple, create a file called quotes.txt with quotes, a new one on each line (make it world readable) ; by default if you then call quotes.php it’ll choose a line & print the text… if you comment out echo randomquote(); you could include quote.php in other code
Here’s the code… enjoy !
$QUOTEFILE=”./quotes.txt”;
function randomquote() {
global $QUOTEFILE;
$quotes = file(“$QUOTEFILE”);
srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);
return $quotes[$randomquote];
}
echo randomquote();