Problem with random script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick

    Problem with random script

    Hi,

    I've an image and a phrase in my home page (index.php) and I'd like to
    change them randomly each time the page is reloaded.
    To achieve this goal, I've created a folder and in this folder I've
    inserted different php files: each file include a different image and an
    associated phrase.
    Now I'd like to create in the index.php a script that each time the page
    is reloaded includes randomly a php file from the folder.
    The result should be that each time the page is reloaded the image and
    the phrase change.
    Can you help me please?
    Many thanks for the support.

    Best,
    Nick
  • Kim André Akerø

    #2
    Re: Problem with random script

    Nick wrote:
    Hi,
    >
    I've an image and a phrase in my home page (index.php) and I'd like
    to change them randomly each time the page is reloaded. To achieve
    this goal, I've created a folder and in this folder I've inserted
    different php files: each file include a different image and an
    associated phrase. Now I'd like to create in the index.php a script
    that each time the page is reloaded includes randomly a php file from
    the folder. The result should be that each time the page is reloaded
    the image and the phrase change. Can you help me please? Many
    thanks for the support.
    One way to do it:

    <?php
    $filelist = glob("dirwithph pfilestoselecta trandom/*.php");
    include($fileli st[array_rand($fil elist)]);
    ?>

    --
    Kim André Akerø
    - kimandre@NOSPAM betadome.com
    (remove NOSPAM to contact me directly)

    Comment

    • Nick

      #3
      Re: Problem with random script

      Many thanks.
      It works fine.
      Nick

      Kim André Akerø ha scritto:
      Nick wrote:
      >
      >Hi,
      >>
      >I've an image and a phrase in my home page (index.php) and I'd like
      >to change them randomly each time the page is reloaded. To achieve
      >this goal, I've created a folder and in this folder I've inserted
      >different php files: each file include a different image and an
      >associated phrase. Now I'd like to create in the index.php a script
      >that each time the page is reloaded includes randomly a php file from
      >the folder. The result should be that each time the page is reloaded
      >the image and the phrase change. Can you help me please? Many
      >thanks for the support.
      >
      One way to do it:
      >
      <?php
      $filelist = glob("dirwithph pfilestoselecta trandom/*.php");
      include($fileli st[array_rand($fil elist)]);
      ?>
      >

      Comment

      Working...