You're here: Home / PHP /

Displaying Random Quotes

Displaying random quotes is the easiest thing to do with PHP. But in case you don't know how, here it is:

<?php
function random_quote()
{
    $quotes = array
    (
        "quote 1",
        "quote 2",
        "quote 3",
        "quote 4",
        "quote 5"
    );
    
    $rval = rand(0, count($quotes) - 1);
    print $quotes[$rval];
}

/* select random quote and print */
random_quote();
?>

Keywords: random quotes, tips of the day, randomize string, php

Share:  del.icio.us logo Save to del.icio.us  digg logo Digg this!

comment.gifAdd your comment

(required, will not be published) (optional)