Jump to content
HomeUserlistGamesWipsExamplesOtherForums
Images Flash Files Examples Audio Files Rules Terms Of Service
[php]Random quote script by Friiks
[php]Random quote script
[php]Random quote script

Hey!


In this tutorial I will teach you how to make a random quote script - a script that will display a random script every time you load the page.

You'll need a server that allows you to run php files and some basic php knowledge!

First create two files - quote.php & quotes.txt.

First open quotes.txt and put your quotes in it this way

Code


Quote1
::
Quote2
::
Quote3::Quote4



You just seperate each quote with "::".

Then open quote.php and input this code

PHP Code


<?

$quotes 
= array();

$content file_get_contents('quotes.txt');

//gets contents of the quotes.txt file

$quotes explode("::",$content);

//makes an array of quotes after they are seperated

$total_quotes count($quotes);

//counts the total number of quotes

echo trim($quotes[mt_rand(0,$total_quotes-1)]);

//echo a random quote :)

?>



So..that's basically it!
It gets the total amount of quotes in quotes.txt and echoes a random one.

Don't be afraid to ask questions to me.

Cheers, Friiks!

Click here to see how my script works



File Info
Downloads0
Ratingrating imagerating imagerating imagerating imagerating image
Comments
Brod's Avatar
Brod


Comments:121
Money:$135

Cool, now I have something to put in that empty spot in my site! :D

24th September 2008 | Report
Samuraikill's Avatar
Samuraikill


Comments:7
Money:$0

Lol, This is cool :)

25th September 2008 | Report