View Single Post
Old Sep 14th, 2005, 11:21 PM   #1
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 3 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
PHP random quote generator script

Well technically this little php snippet doesn't generate random quotes, that would just be weird However, it does select a quote randomly from a user generated quote database.

<?php
	function quote_generate()
	{
		$quote = array("An apple a day keeps the doctor away.",
		"A bird in the hand is worth two in the bush.");

		return($quote[rand(0, count($quote) - 1)]);
	}

	echo quote_generate();
?>

Simple and effective methinks. To add your own quotes just enclose the string in " " and separate each of them by commas. I use a similar variant of the script on my site to have random quotes pop up in the news page when people visit the site.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote