tags:

views:

23

answers:

1

OK, whats the best solution in php to search through a bunch of files contents for a certain string and replace it with something else.

Exactly like how notepad++ does it but obviously i dont need the interface to that.

+4  A: 
foreach (glob("path/to/files/*.txt") as $filename)
{
    $file = file_get_contents($filename);
    file_put_contents($filename, preg_replace("/regexhere/","replacement",$file));
}
Byron Whitlock