Random Quote

April 13th, 2009
| Tags: random quote
Tutorial Description:
Tutorial Description:
Learn how to create a random quote script.
For this tutorial, we’ll only need one file, lets get started.
<?php
// Each below line is another quote, add as much as you want.
$quote[] = "Quote number 0";
$quote[] = "Quote number 1";
$quote[] = "Quote number 2";
// Get random number.
$random = rand(0, count($quote) - 1);
// Lets print our the quote.
echo $quote[$random];
?>
You can see what I’m doing in the script with the comments.
Remember, arrays always start with 0, not 1.
Leave a comment
| Trackback

