多くのフォルダのみを含むディレクトリがあり、それらの各フォルダにはURLを含むテキストファイルがあります。私がやろうとしているのは、各フォルダでそのテキストファイルを開き、それを編集して各 URL を \n 文字で区切った 1 行の URL
これはこれまでの私のコードです
$path = "localpath here";
$handle = opendir($path);
while ($file = readdir($handle)) {
if(substr($file,0,1) !="."){
$text = preg_replace('/\s+/', '', $file);
//echo $text."</br>";
$blast = fopen("$path/$text/$text.txt", 'r') or die("can't open file");
//echo $blast;
while (!feof($blast)) {
$members[] = fgets($blast);
//echo $members;
}
}
}
foreach($members as $x=> $order){
echo $order."</br>";
$string = trim(preg_replace('/\s+/', ' ', $order));
$linksonly = "write.txt";
$linksonlyHandle = fopen("$path/$text/$linksonly", 'a') or die("can't open file");
fwrite($linksonlyHandle,$string.'\n');
fclose($linksonlyHandle);
}
closedir($handle);