Web Hosting Talk







View Full Version : Another PHP Question..


Studio64
06-03-2002, 03:32 AM
I hate posting this b/c it's a really stupid question. I searched php.net and I've search the forum here.... I think my lack of a solution might be my problem to find the exact terms to search for....

So here's the problem (I'm assuming I'm just missing a text function, actually I know... I just can't remember the name)....

OK..

Form Input Is

hello blah blah blah
blah but, on a new line
more and more blah again a new line

End Form Input

But The Output Is


hello blah blah blah blah but, on a new line more and more blah again a new line


End Output...

OK... Refresh me on the function :D

Rich2k
06-03-2002, 06:40 AM
All you need to do is simply str_replace the new line characters

e.g.

$output = str_replace ("\n", "", $input);
$output = str_replace ("\r", "", $output);

weeps
06-03-2002, 08:06 AM
actually,


$output = str_replace ("\n", "<BR>", $input);
$output = str_replace ("\r", "<BR>", $output);


he forgot the br's :-)

Studio64
06-03-2002, 12:08 PM
Thats the one... Thanks

driverdave
06-03-2002, 02:58 PM
Check out the nl2br function. The kludge above reminds me of when I wrote number_format myself :)

http://www.php.net/manual/en/function.nl2br.php

Studio64
06-08-2002, 05:08 AM
Aww man... But, I love re-inventing the wheel...

webx
06-08-2002, 01:57 PM
Originally posted by Studio64
Aww man... But, I love re-inventing the wheel...

How about writing PHP-release-Studio64 ;)