Page 1 of 1

new line

Posted: Tue Mar 13, 2007 3:07 pm
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

Posted: Tue Mar 13, 2007 3:16 pm
by flann
\n where ever you want to put a newline should work I would think

Posted: Tue Mar 13, 2007 5:33 pm
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.

Posted: Tue Mar 13, 2007 11:27 pm
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.

Posted: Wed Mar 14, 2007 1:32 am
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.