View Single Post
Old 06-08-2005, 06:54 PM  
Rice_Master
Confirmed User
 
Join Date: Mar 2001
Posts: 1,582
Quote:
Originally Posted by Rice_Master
Code:
<?
   $howmany = 3; // The number of quotes to display.
   $quoteFile = "quotes.txt";  //File holding qoutes

   $fp = fopen($quoteFile, "r");   //Opens file for read
   $content = fread($fp, filesize($quoteFile));
   $quotes = explode("\n",$content);   //Put quotes into array
   fclose($fp);   //Close the file

   For ($i = 0; $i < $howmany; $i++) {
 
   srand((double)microtime()*1000000);  // randomize
   $index = (rand(1, sizeof($quotes)) - 1); //Pick random qoute

   echo $quotes[$index] . "<br>"; //Print quote to screen

   }

?>
That'll work.
There's a chance of getting the same quote twice with that code though.
Rice_Master is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote