PHPBuilder - Display a random quote

RSS Twitter
Snippets Other

Display a random quote

by: Andrew
April 21, 2006

Version: 0.1

Type: Sample Code (HOWTO)

Category: Other

License: GNU General Public License

Description: This code uses an array and a random number to display a quote. You could change it to be random anything..

$quotes = array(    
    1=>"quote 1",
    2=>"quote 2",
    3=>"quote 3",
    4=>"quote 4",
    5=>"quote 5",
    6=>"quote 6",
    7=>"quote 7",
    8=>"quote 8",
    9=>"quote 9",
    10=>"quote 10");

$random_number=rand(1, count($quotes));
$nums = count($quotes) - 1;
echo "Over $nums qyotes Hit refresh for another quote.<br /><br />";

Comment and Contribute

Your comment has been submitted and is pending approval.




(Maximum characters: 1200). You have characters left.