SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random page pick

    Hi, i have a website that loads content from includes.
    What i want to do is ramdomly pick which content to disply.
    For instance:

    PHP Code:
    // randomly pick between the two following includes
    include_once("inc/content1.php");
    // or
    include_once("inc/content2.php"); 
    Any ideas on how i can do this?

    Thanks in advance

    David

  2. #2
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $files = array("file1.php""file2.php""file3.php");
    include_once(
    $files[array_rand($files)]); 

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, it is always so simple, its just knowing how.


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
  •