PHP custom Traverse directory All Files dir (), Readdir () function
Method One: Use Dir () to traverse the directory
Dir () function, returns the Directory class instance when successful
The syntax format for the PHP dir () is:
Dir
PHP/** * PHP non-recursive implementation query all files in this directory * @param unknown $dir * @return multitype:|multitype:string*/functionScanfiles ($dir) { if(!Is_dir($dir )) return Array (); //compatible with each operating system
This example describes how PHP uses the Glob function to traverse a directory or folder. Share to everyone for your reference. The specific analysis is as follows:
When it comes to PHP traversal directory Many of our friends will think of Opendir
PHP custom traversal of all files in the directory method
Header (' Content-type:text/html;charset=utf-8 ');/*** method One: Use Readir () to traverse the directory*/function Listdir ($dir){ if (Is_dir ($dir)) { if ($handle = Opendir
Directory traversal is a PHP design often used in a function, many PHP projects have this function module. Today in this article to illustrate the example of PHP using a custom function to traverse all the files in the directory method. The specific
Traverse the directory or traverse the directory of the specified type of file, this is every child shoe in the writing program will inevitably use. PHP itself also provides a lot of gray useful functions, use them correctly, there is no mistake.
Today, we mainly introduce the application of file directory function in the development of PHP website. In the development of PHP website, we often need to read directory file information or create a directory to store the necessary files, and when
Write a class that traverses directories and replaces file contents in bulk
Write this class before you need it.
Function:
1 traversing all files in the directory (you can specify the suffix name)
2 Bulk Replace file contents (regular, String)
3
Method One: Use Dir () to traverse the directory
Dir () function, returning a directory class instance when successful
The PHP dir () syntax format is:
Dir (directory)//directory the name of the directory where the file name needs to be displayed,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.