Hello all
i want to open a dir and change a word in all files
so ive got this far
// open dir and get list of files
if ($dir = @opendir("/tmp"))
{ while (($file = readdir($dir)) !== false)
{ $files[] = $file; }
closedir($dir); }
foreach ( $files as $file )
{
// open each file
if(! $open_file = file($file))
{
// echo "CANT OPEN $file <br>";
}
else
{
//echo "OPENED FILE $file <br>" ;
foreach($open_file as $a)
{
$a = preg_replace("/(.*)(word)(.*)/", "$1 newword $3", $a) ;
}
But this doesnt save the files ... how would i do this ?
Thanks
Al