SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Mar 2001
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Showing a random statement

    At the top right of my web site: http://www.azfans.com/ I am displaying some text right now it says "Because the Suns will win an NBA title... eventually!" I would like this to show a random message from a number of different statements...

    How would I be able to do this with php?

    Thanks,

    Jon

  2. #2
    SitePoint Enthusiast PicklePete's Avatar
    Join Date
    Apr 2008
    Location
    England
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    PHP Code:
    $quotes = array('This is a quote''To be or not to be''hamilton rocks');
    echo 
    $quotes[rand(0count($quotes) - 1)]; 

  3. #3
    SitePoint Evangelist BJ Duncan's Avatar
    Join Date
    Jun 2007
    Location
    North Richmond
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alternatively if you have the quotes stored in a database you could call them and also include code which will let you grab stats on how many times it has been displayed etc.

    But if you are not going by way of database then follow PicklePete's advise.
    Regards,
    BJ Duncan

  4. #4
    SitePoint Addict
    Join Date
    Mar 2001
    Posts
    379
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfecto! Gracias!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •