DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Random Quotes
Called as quotes.php it will display a single random quote. Called as quotes.php?all=1 it will display all quotes in an unordered list. No database is required, and it should be fairly obvious how to add new quotes.
<?php
$quotes[] = "Boys like hugs too.";
$quotes[] = "Ooh! Train!";
$quotes[] = "La rue est a nous.";
$quotes[] = "The future is unwritten.";
if($all==1) {
echo "<ul>";
for($i=0; $i<=count($quotes)-1; $i++) {
echo "<li>".$quotes[$i]."</li>";
}
echo "</ul>";
} else {
srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);
echo $quotes[$randomquote];
}
?>





