nl2br() would serve that purpose as well. See the Strings section of the Functions Reference in the manual.
Mike Frazer "Martin Towell" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > $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:[EMAIL PROTECTED]] > 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php