Home > Article > Backend Development > A simple way to get a directory list in php_PHP tutorial
This article mainly introduces a simple way to get a directory list in php, involving the skills of php operating directories, which is very practical and needed. Friends can refer to it
The example in this article describes how to simply obtain a directory list in PHP. Share it with everyone for your reference. The specific implementation method is as follows:
?
3 4 513 14
15
|
<🎜>function list_directory_content($dir){<🎜>
<🎜>if(is_dir($dir)){<🎜>
<🎜>if($handle = opendir($dir)){<🎜>
<🎜>while(($file = readdir($handle)) !== false){<🎜>
<🎜>if($file != '.' && $file != '..' && $file != '.htaccess'){<🎜>
<🎜>echo ''
.$file.' '."n"; } } closedir($handle); } } } ?> |