Home >Backend Development >PHP Tutorial >A simple way to get a directory list in php, get a directory list in php_PHP tutorial
The example in this article describes a simple way to get a directory list in php. Share it with everyone for your reference. The specific implementation method is as follows:
<?php function list_directory_content($dir){ if(is_dir($dir)){ if($handle = opendir($dir)){ while(($file = readdir($handle)) !== false){ if($file != '.' && $file != '..' && $file != '.htaccess'){ echo '<a target="_blank" href="'.$dir.$file.'">' .$file.'</a><br>'."\n"; } } closedir($handle); } } } ?>
I hope this article will be helpful to everyone’s PHP programming design.