Coding random Include page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Coding random Include page

    Hi bro, kindly help out with this... <?php
    include_once $_SERVER['DOCUMENT_ROOT'] . '/variables/variables.php';
    include_once $_SERVER['DOCUMENT_ROOT'] . '/variables/random.php'; ?> ..... so how can i include a random page into this file? e.g because i got 67page to include on this page? how can i make it random.

    #2
    using array

    Comment


      #3
      PHP Code:
      <?php
      $filenames 
      = array();
      if (
      $handle opendir('/variables')) {
          
      $n 1;
          while (
      false !== ($file readdir($handle))) {
              if (
      $file != "." && $file != "..") {
                  
      $filenames[$n] = $file;
                  
      $n++;
              }
          }
          
      closedir($handle);
      }
      $num rand(count($filenames));
      include_once 
      $_SERVER['DOCUMENT_ROOT'] . '/variables/'.$filenames[$num];
      ?>

      Comment


        #4
        Thank, i will try this out.

        Comment


          #5
          Bro, this work but i can u help fix a bug.

          Comment


            #6
            PHP Code:
             <?php
            $atef 
            = array( 
            'page1',
            'page2'
            'page3'
            );
            $atef $atef rand(0, (count($atef)-1)) ]; 
            require(
            $atef.php); 
            ?>

            Comment

            Working...
            X