Welcome and have a nice stay !       login   register   need help?  

 Page Info

Page Title: Random Quote Generator 1.0
Description: Now you can add in a fun random quote (or three, or twelve...) to your php templates!
Author: Jamie Keane
Submission Date: 15-12-2005 17:03

 Rating & Comments

View or add comments: (0)
Average members rating: 0



Code :
// hide source code
// hide line numbers

 1  <?php
 2  
 3  
// string randquote(string $infile, string $delim):
 4  //
 5  // generates a random quote, separated by $delim.
 6  // $delim defaults to the fortune-style double-% on its own line (n%%n).
 7  
 8  
function randquote($infile$delim "n%%n")
 9  {
10      
// error trapping!
11      
if(!IsSet($infile))
12      {
13          die (
"You didn't specify a parameter for $infile!");
14      }
15      
// attempt to open $infile
16      
if(!file_exists($infile))
17      {
18          die (
"$infile was not found!  check your paths!");
19      }
20      else
21      {
22          
$fp fopen($infile"r")
23              or die (
"Error opening file!");
24      }
25      
// okay, let's get going.
26      
$contents fread($fpfilesize($infile));
27      
$quote_arr explode($delim,$contents);
28      
fclose($fp);
29      
// feed the Randomness Monster (tm)
30      
srand((double)microtime()*1000000);
31      
// generate random quote index
32      
$quote_index = (rand(1sizeof($quote_arr)) - 1);
33      
// get quote at $quote_index and return it
34      
$herequote $quote_arr[$quote_index];
35      return 
$herequote;
36  }
37  
?>


Donation:

If you like our free quality work, make a donation by using Paypal and tell us what you would like to see improved on our site for the next few months.

Comments


No comments yet

 Site Activity
Currently online: 0 member(s), 43 guest(s) : All members offline.


 Quick Menu
sitemap
search
galleries
main
forums


 Our Services

Main Projects
Designers For Hire
Unique LDU Skins
LDU Skins For Sale
Seditio Skins For Sale
Templates For Sale


 Statistics
18582 registered members,
1870 topics in forums,
21584 posts in forums,
13589666 pages served since 2004-05-09.
more


 7th Version Design

+++
top