1、遍历文件夹
scandir
2、原生的迭代器Iterrate
$scan_dir = "txtDir"; //下面会遍历txtDir 下面所有字文件夹中的文件哦 $dir_iterator = new RecursiveDirectoryIterator($scan_dir); $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST); //$iterator 变量中会存储所有文件
遍历处理文件: foreach ($iterator as $file) { if ($file->isFile()) { $s = $file->getPathname(); $file_name = $file->getFilename(); if($file_name == ‘a.txt‘){ continue; } }
就是这么简单
原文地址:https://www.cnblogs.com/cbugs/p/9245796.html
时间: 2024-10-09 01:54:34