PHP obtains a simple example of recursive algorithm for all files in a folder
As shown below:
function my_scandir($dir) { $files=array(); if(is_dir($dir)) { if($handle=opendir($dir)) { while(($file=readdir($handle))!==false) { if($file!="." && $file!="..") { if(is_dir($dir."/".$file)) { $files[$file]=my_scandir($dir."/".$file); } else { $files[]=$dir."/".$file; } } } closedir($handle); return $files; } } }
The above is the simple example of the recursive algorithm of all files in the folder brought to you by the editor. I hope everyone supports me~
Related Articles
PHP prompts the solution to Call-time pass-by-reference has been deprecated in
This problem occurred when a client configured the server today, mainly because he chose the wrong problem. It is better to dist first by default, and choose this for actual application.2012-05-05php jsonp single quote escape
JSONP (JSON with Padding) is an unofficial protocol. Its implementation method is roughly: let the client decide the Javascript function name to callback, and put the JSON data into the callback function name on the third-party server. The return is a function call script with the parameter JSON data. The browser loads the script and executes it to achieve the purpose of obtaining third-party data.2014-11-11Detailed explanation of the usage example of Zend Framework router
This article mainly introduces the usage of Zend Framework router, and analyzes the functions, definitions and basic usage methods of Zend Framework router in combination with examples. Friends who need it can refer to it.2016-12-12Yii2 Method of outputting xml format data
This article mainly introduces the relevant information about Yii2's method of outputting xml format data. The editor feels that it is of great reference value. Here we share it with my platform for your reference2016-05-05Example of the tp framework (thinkPHP) function to achieve three login password errors after locking account function
This article mainly introduces the tp framework (thinkPHP) to realize the function of locking the account after three login password errors. Combined with the example form, it analyzes the password account locking function based on thinkPHP login judgment, flag bit operation and other operations. Friends who need it can refer to it2018-05-05Summary of problems about laravel log writing failure
Today, the editor will share with you a summary of laravel log writing failure problems, which is of good reference value and hope it will be helpful to everyone. Let's take a look with the editor2019-10-10PHP implements the development of simple crawlers
This article will share with you the ideas and code of how to use php to develop simple web crawlers. It is very simple. Friends in need can refer to it.2016-03-03Yii2 framework controller, routing, and Url generation operation examples
This article mainly introduces Yii2 framework controller, routing, and Url generation operations. It analyzes related principles and operation techniques such as Yii2 framework controller, routing, and url generation jump in combination with examples. Friends who need it can refer to it.2019-05-05Comparison between PHP static delay binding and ordinary static efficiency
This article mainly introduces the relevant information on the comparison of PHP static delay binding and ordinary static efficiency. Here are examples to illustrate the efficiency issues between them. Friends who need it can refer to it.2017-10-10Detailed explanation of the update data instance (demo) of ThinkPHP implementation
This article introduces you to a detailed explanation of the examples of thinkingphp to update data and five methods of thinkingphp to update databases. The introduction of this article is very good and has reference value. Interested friends can refer to it.2016-06-06