ereg_replace help :(
Posted: Wed Sep 04, 2002 3:19 am
OK been trying to read on this for about a week on and off and I cant get this to work. The code below needs to read a flat file, find a string that starts with Counterfile and have anything else after that on its own line. Replace it with a with the Counterfile but a new path after that, Again its on its own line. I got it to read just that one line, but I cant figure out how to replace it on the text file and write the new information on to the file. Any help Please
Code: Select all
$fp = fopen ("$htaccess", "aw");
$fcontents = file ("$htaccess");
foreach($fcontents as $value){
if(ereg("Counterfile (.*)", $value, $matches)){
echo $matchesї1];
$replace = ereg_replace( "Counterfile $matchesї1]","$counter_syntax\n","$fcontents");
}
}
//
// close the file
//
fclose($fp);