Re: ereg_replace help

From: Date: Mon, 04 Feb 2002 08:23:15 +0000
Subject: Re: ereg_replace help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83353@lists.php.net to get a copy of this message
nl2br() would serve that purpose as well. See the Strings section of the Functions Reference in the manual. Mike Frazer "Martin Towell" <martin.towell@world.net> wrote in message news:6416776FCC55D511BC4E0090274EFEF5089E7D@exchange.world.net... > $lines = file("filename_here.blah"); // read in file as an array > $content = implode("\n", $lines); // join it all back together > $new_cont = ereg_replace("from", "to", $content); > fopen(...); fputs(..., $new_content); fclose(...); > > > if your intent is to replace all new lines with <br>'s then use this instead > ... > > $lines = file("filename_here.blah"); // read in file as an array > $content = implode("<br>", $lines); // join it all back together > fopen(...); fputs(..., $content); fclose(...); > > > hope this helps > > -----Original Message----- > From: John P. Donaldson [mailto:johnpdonaldson@yahoo.com] > Sent: Monday, February 04, 2002 3:39 PM > To: php > Subject: [PHP] ereg_replace help > > > I have a file open and can successfully write to it, > but I was to be able to search for a certain string of > text and replace it with a string of text. I can't > figure out how to construct a proper ereg_replace > statement to search through this file and do the > replacing. Examples I've seen are in the manner of: > > $text = "line1\nline2\n"; > fputs(ereg_replace("\n", "<br>", $text)); > > But how do I set the value of $text to be the entire > contents of the text file I've got open so it can > search through the entire file to find matches and > replace those matches? Any help is greatly > appreciated. > > Thanks, > John > > __________________________________________________ > Do You Yahoo!? > Great stuff seeking new owners in Yahoo! Auctions! > http://auctions.yahoo.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#83353) next »