About an include rotation code

Discussion in 'PHP' started by Codythebest, Apr 29, 2007.

  1. #1
    I'm looking about a little PHP code to rotate randomly some include .inc.php
    Any idea???
     
    Codythebest, Apr 29, 2007 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    You want to randomly rotate a portion of a page?

    Refresh this page a few times and watch the featured product change on a random basis. If that is what you want to do I will PM you the source code.
     
    Colbyt, Apr 30, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    nico_swd, Apr 30, 2007 IP
  4. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    <?php
    
    
    /*
     list the files inline here
    */
    $files = array(
    	'file1.php.inc',
    	'file2.php.inc',
    	'file3.php.inc'
    	// etc.
    );
    
    /*
     or load them from a flatfile containing a filename on each line:
    		file1.php.inc
    		file2.php.inc
    		file3.php.inc
    */
    $files = file('/path/to/file');
    
    // and now include a random file
    include $files[array_rand($files)];
    ?>
    
    PHP:
     
    sea otter, Apr 30, 2007 IP