...

View Full Version : determine "real" newlines and string "\n"



V@no.
12-27-2003, 02:50 PM
Hi!
I was wondering is there any way PHP could determine when in the text is "real" newline or its a string as "\n" ?
for example code like this:
<?php
highlight_string("<?php\n\$text = \"Something\non\nthree lines\";\n?>\n\n");
highlight_string("<?php\n\$text2 = \"Semething
on
three lines\"\n?>");
?>
if u try this code, it will show u exactly identical two stings, even though first one was only using "\n" sting but second was using "real" newlines (or maybe return caret if u prefer)

so, is there any way to determin it?

thank you!

firepages
12-27-2003, 03:24 PM
they are one and the same , they are both newlines "\n"
the only difference is that on win32 you would expect to find "\r\n" & on *NIX plain old "\n"

in saying that perhaps try

if( strpos( $str , "\n" )!==false){ //etc// }

V@no.
12-27-2003, 03:33 PM
so, basicaly there is no way I can process through PHP a text file and make from it an identical copy?
I'm working a script translator, witch has an include for a language script, after witch all needed text for translation is in $lang array and it displays the textarea for each item in the array for translation. Some of the items uses "\n" string and some uses "real" newlines (witch makes easier to read). After translation it saves new file but every "\n" strings become as newlines...if I add a slash to "\n" it will make "real" newlines as strings too...
so, otherwords, the text that was entered by user will be different after it was saved.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum