read())) { if ($entry == '.' || $entry == '..' || match_name($entry, $filter)) { continue; } $Entry = $source . '/' . $entry; if (is_dir($Entry)) { full_copy($Entry, $target . '/' . $entry, $filter); continue; } copy($Entry, $target . '/' . $entry); } $d->close(); } else { copy($source, $target); } } /** * 删除文件夹及内部文件 * * @param $dir * @return bool */ function del_tree($dir) { $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { (is_dir("$dir/$file")) ? del_tree("$dir/$file") : unlink("$dir/$file"); } return rmdir($dir); } /** * 判断名称是否匹配集合 * * @param string $name * @param array $set 正则表达式集合 * @return bool|void */ function match_name($name, $set) { foreach ($set as $value) { if (preg_match($value, $name)) { return true; } } }