A simple way to get a directory list in php_PHP tutorial

WBOY
Release: 2016-07-13 10:00:45
Original
1277 people have browsed it

A simple way to get a directory list in php

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:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

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);

}

}

}

?>

1 2

3

4 5

67 8 9 10 11 12
13
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); } } } ?>
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/973124.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/973124.htmlTechArticleHow to simply get the directory list in php. This article mainly introduces the simple method of getting the directory list in php, involving php operations. The directory skills are of great practical value. Friends in need can refer to it...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template