function test(){$hostdir= iconv("utf-8","gbk","C:\Users\原萬里\Desktop\日常筆記") ; //iconv()轉換編碼方式,將UTF-8轉換為gbk,若是報錯在gbk后加//IGNORE$filesnames = scandir($hostdir); //scandir() 函數返回指定目錄中的文件和目錄的數組。默認升序排列,foreach ($filesnames as $name) {if($name!=".." && $name!=".") //遍歷結果中會多出‘.’以及‘..’,沒有用處,不予處理;{$cipath = $hostdir.$name;$cjfilenames = scandir($cipath); //根據情況再決定是否再向下遍歷一次foreach($cjfilenames as $cjname){if($cjname!=".." && $cjname!="." &&!is_dir($cipath."/".$cjname)){$str = file_get_contents($cipath."/".$cjname);file_put_contents("e:/test.txt",$str,FILE_APPEND);}}}echo "\n";}}
?