| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,901
|
Running str_replace on a fread txt file
<php-newbie-alert /> As the title implies, I'm trying to run a str_replace on an included/read document. Basically, I'm trying to import the contents of a .txt file and convert \n to <br /> tags. I can do the whole fopen …*fclose sweep just fine. Before the fclose, I declare the contents (string) of the file as a variable. I'm then attempting the run the variable through a str_replace process. It will work fine if I remove the str_replace part. It will work fine (w/ the str_replace) if the variable string doesn't originate from an fread document. I just can't seem to get the two to work together. Here's what I have. Code:
The str_replace is just being ignored. Help? TIA |
|
|
|
|
|
#3 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,901
|
Scrap all that, found that Tex-Edit Plus was to blame. Silly arse was using non-standard invisible characters to indicate new lines. Swapped to another text app and went with ereg_replace() instead. :happybunny: |
|
|
|
#6 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,901
|
I ended up using this: Code:
It enables me to format the contents of the txt file in a way that matches the surrounding markup (à la view source). nl2br() is great, but a little too basic for my (pedantic) needs. I'm wearing my PHP is fun! badge today. |
|
![]() |