This article mainly introduces the way in which PHP replicates directories and subdirectories recursively, including the skills of PHP recursion and directory operation, which has some reference value, and the friends who need it can refer to the following
This example describes how PHP replicates directories and subdirectories recursively. Share to everyone for your reference. The implementation methods are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16-17 |
<?php function Recurse_copy ($SRC, $dst) {$dir = Opendir ($SRC); @mkdir ($DST); while (false!== ($file = Readdir ($dir)) {if ($file!= '. ') && ($file!= ' ... ')) {if (Is_dir, $src. '/' . $file)) {recurse_copy ($src. ') /'. $file, $dst. ' /'. $file); else {copy ($src. /'. $file, $dst. ' /'. $file); }} closedir ($dir); }?> |
I hope this article will help you with your PHP program design.