new line

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
serial
Forum Newbie
Posts: 1
Joined: Tue Mar 13, 2007 2:57 pm

new line

Post by serial »

hi there i have made a script that will read information from a web page and store the information into a .txt file this is what i get in the .txt file

ihncmagi ctitcnuonec ohoi ronmtev baaerskn hulinasoratco miena norgeo ivigrnai lhkaaomo pienyanavnsl esolainhddr ieomnexwc aalsak diinaan soigwtnahn balmaaa ahiiaw asnniotem uasteacstmhss

what i have done is used str_replace() for the <br /> with " " so thats how i get the spaces but what i want to do is store it in the text file like :

rhsdenaidlo
enjysrwee
waaihi
etc

i thought the if i used str_replace() and changed the " " to "\n" then it would work but it just adds the words together please can someone help

thank you
flann
Forum Commoner
Posts: 38
Joined: Tue Aug 23, 2005 10:48 pm

Post by flann »

\n where ever you want to put a newline should work I would think
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

It depends on your server software. Windows typically uses "\r", *nix "\n". in your replace statement, replace combinations of "\n\r" first, the move on to the individual characters.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Windows uses \r\n, (older?) Macs \r, *nix \n.

PHP helps you out with PHP_EOL being the native form for the operating system you're currently on.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Dude, I hecka screwed that up. I meant to say what feyd said, but for some reason it came out like what I said. Sorry.
Post Reply