Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php traverse all files and subfolders under a folder

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "php how to traverse all the files and subfolders under the folder", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "php how to traverse all the files and subfolders under the folder" bar!

Traverse the directory and store the results in an array. Support php4 or above. Php5 can later replace the while loop with the scandir () function.

The copy code is as follows:

Another method of implementation

The copy code is as follows:

Function fetchDir ($dir) {

Foreach (glob ($dir.'\ *') as $file) {

Echo $file, "\ n"

If (is_dir ($file)) {

FetchDir ($file)

}

}

}

FetchDir ("D:\ wamp\ www\ any")

You can also replace'\ * 'with DIRECTORY_SEPARATOR.'*' and'\ n' with PHP_EOL, so you can cross platforms.

Thank you for your reading, the above is the content of "how php traverses all files and subfolders under the folder". After the study of this article, I believe you have a deeper understanding of how php traverses all files and subfolders under the folder. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report