I need to replace some html code in about 100 files.
Wanted to do this through code, and am using fgets() to get a line at a time
from the file, this string is saved in variable $line.
Then I check for the occurrence of the search string in $line using
If found, I echo some statements, and I wanted to replace the "search" text
with "replace" text using str_replace().
The strange thing is that while the code is able to search out the strings
correctly, it doesn't replace the text. The $line var loses its value for no
I check for the occurrence of the search string
if($pos=strpos ($line, $strfrom))
but when within the if block I try to echo $line I don't get the value, so
str_replace doesn't work either.
everything else works fine, the strangest thing is that I tried echoing the
$line value before the if block and it doesn't print anything, but it works
for the if condition.
I am getting the no of files and the line nos, where the search string
occurs, but no replacements happening. This is the replacement code:
$newline=str_replace ($strfrom, $strto,$line);
echo "<br>New Line $newline";
Am I missing something really obvious here?
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.370 / Virus Database: 205 - Release Date: 06/05/2002
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php