Wednesday, August 27, 2014

9:10 AM
In this article, we are discuss about how to list all the folders under a specified location with PHP.

<?php
//path to directory to scan
$directory = '.';
 
//get all files in specified directory
$files = glob($directory . "*");
 
//print each file name
foreach($files as $file)
{
 //check to see if the file is a folder/directory
 if(is_dir($file))
 { 
 ?>
      <li>
        <div class="dropPlaylist" id="<?php echo basename($file); ?>">
          <a href="?playlist=<?php echo basename($file); ?>"> 
            <?php echo basename($file); ?> 
          </a>
        </div>
      </li>
      <?php }
}
 
?>

0 comments: