Jump to content

Auto edit all files in subfolders


Hamlets666

Recommended Posts

[code]
<?php
foreach (glob("*.txt") as $filename) {
// get contents of file, line by line, and put into an array
$data = file_get_contents($filename);
$data = str_replace("was so", "is now", $data);
$file = fopen($filename, "w");
fwrite($file, $data);
// close file
fclose($file);}
?>
[/code]
I believe this would work for the txt files in a directory but not its subdirectory...
hope it helps.
Ted

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.