Hi all,
I have a textfile with some contents (6 lines)
I "fopen" the file and want to replace the line "avail" with "unavail". The code below doesn't work. Can anyone help me ?
Thanx in advance
Olli
$comp = $destdir.$textfile;
$contents = file($comp);
$fp = fopen ($comp,"w");
for($i=0; $i<count($contents); $i++)
{
if(eregi("avail",$contents[$i]))
{
fwrite ($fp,"unavail"."\n");
}
else
{
fwrite($fp, $contents[$i]);
fwrite($fp, "\n");
}
}
fclose ($fp);