Friday, December 9, 2011

Php Code to explore every directory and files in a path

<?php

calldir("lightbox");
function calldir($path)
{
if ($handle = opendir($path)) {
    echo "Directory handle: $handle</br>";
    echo "Files:</br>";
     $i=0;
    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        echo "$file</br>";
  $data=explode(".",$file);
  if($data[1]==''&& $file!="." && $file!="..")
  {
  if (is_string($data[0]))
   {
  //echo $file.'</br>';
  $url=$path.'/'.$file;
  calldir($url);

  }
  }
    }

  
    closedir($handle);
}
}
?>

No comments:

Post a Comment