Tuesday, January 29, 2013

Display All files and Contents in a Directory.

Display all files name with content.

(Using RecursiveDirectoryIterator PHP >=5.1.2)

-is_file check the each object values in directory list. suppose file name is occurred display the filename and content.
-highlight_file() display the file content.

<?php

 $path = "C:/xampp/htdocs/samplejoomla/application/controllers/administrator/";

      $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path),  RecursiveIteratorIterator::SELF_FIRST);

      foreach($objects as $name => $object){
          echo '<b>'.$name."</b> \n <br/>";
          if(is_file($name))
          {
            echo highlight_file($name);
           
          }
           echo "<br/><br/><br/>";

          }

?>

No comments:

Post a Comment