Re: replacing a line in a file

From: Date: Tue, 13 Mar 2001 23:55:32 +0000
Subject: Re: replacing a line in a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-43737@lists.php.net to get a copy of this message
that could work but i dont want to append the new line a the bottom which it looks like thats what your doing. i need to replace the line where it is <-----CoreComm-Internet-Services---http://core.com-----> (Jon Marshall CoreComm Services Chicago) (jonathon.marshall@core.com Systems Engineer II) (enthalpy@core.com Network Operations) <-----Enthalpy.org-------------http://enthalpy.org-----> (enthalpy@enthalpy.org The World of Nothing) <------------------------------------------------------> On Wed, 14 Mar 2001, Henrik Hansen wrote: > maybe this? > > while($line = fgets($fp, 1024)) { > $line = str_replace("replace_this", "with_this", $line); > $content .= $line; > } > > fwrite($fp, $content); > > -- > Henrik Hansen > ----- Original Message ----- > From: "enthalpy" <enthalpy@core.com> > To: <php-general@lists.php.net> > Sent: Wednesday, March 14, 2001 12:29 AM > Subject: [PHP] replacing a line in a file > > > > > > having problems replacing a line in a file. > > > > need to search the whole document for a string and then replace that line > with a string. > > > > any ideas? > > > > this is causing lots of problems now. > > > > $fpoint3 = fopen ($testshadow, "r+") or die("couldnt open shadow file > again"); > > $contents = fread ($fpoint3, $shadowfilesize); > > fputs ($fpoint3, ereg_replace("$data[0]:$shadow[1]", > > "$data[0]:$data[1]", > $contents)); > > fclose ($fpoint3); > > > > any ideas? > > > > > > <-----CoreComm-Internet-Services---http://core.com-----> > > (Jon Marshall CoreComm Services Chicago) > > (jonathon.marshall@core.com Systems Engineer II) > > (enthalpy@core.com Network Operations) > > > > <-----Enthalpy.org-------------http://enthalpy.org-----> > > (enthalpy@enthalpy.org The World of Nothing) > > <------------------------------------------------------> > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#43737) next »