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.