The following code loads the contents of a text file and randomly displays a line from it. You can use this to display a random quote on a page every time it loads.
- $file= "quotes.txt";
- $quotes = file($file);
- $randomquote = rand(0, count($quotes)-1);
- echo $quotes[$randomquote];
It works by loading a file into memory and picking a line from that file at random. Here is a sample file you might want to use.
- This is the first quote - Person One
- This is the second quote - Person Two
Fill this with your own quotes and you are away.
Very small but simple little snippet that did just what was needed. Thanks