Zend - The PHP Company




Text

Add Code


Random Text Quote  

Type: code fragment
Added by: Lysander
Entered: 12/10/2002
Last modified: 31/10/2001
Rating: - (fewer than 3 votes)
Views: 4547
Chooses a random line of text from a list and displays it.


<?php
//Put each line of text to be chosen from in the form
//$line[] = "your text";

$line[] = "Line 1";
$line[] = "Line 2";
$line[] = "Line 3";


$num count($line) - 1;
srand ((double) microtime() * 1000000);
$random rand(0,$num);

$oneliner $line[$random];
echo 
"<P>$oneliner</P>"
?>


Usage Example




Rate This Script





Search



This Category All Categories