View Single Post
Old 10-09-2008, 08:52 AM   #1 (permalink)
Normo
The Contributor
 
Normo's Avatar
 
Join Date: Oct 2008
Location: UK
Posts: 30
Thanks: 0
Normo is on a distinguished road
Default Adding content to a specific line in file

I'm relatively new to PHP so bare with me.I'm trying to replace a specific line to a file. This is my code so far:
PHP Code:
$string "Blah blah blah
<!-- comment -->"
;
$file fopen("file.txt""r"); // Open file

if($file){
while(!
feof($file)){  // Before end of file
$read fgets($file1000);  // read line
if ($read=="<!-- comment -->"){ // if right line
$read $string// change to variable
}}
fclose($file);

I'm unable to test this at the moment, so if someone could check this and/or suggest anything better that would be helpful.

Cheers.
Normo is offline  
Reply With Quote