RE: [PHP] Convert textarea post data from plain text to html using php..how?
| From: | Gryffyn, Trevor | Date: | Tue, 14 Sep 2004 15:27:27 +0000 |
| Subject: | RE: [PHP] Convert textarea post data from plain text to html using php..how? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-196629@lists.php.net to get a copy of this message | ||
I stand corrected.
Nl2br() is still useful when dealing with outputting data from textarea
form elements... If you're outputting to a browser at least. But yes,
it only inserts a <br \> where there's a \n, it doesn't replace \n and
doesn't do anything with \r's.
-TG
> -----Original Message-----
> From: John Holmes [mailto:holmes072000@charter.net]
> Sent: Monday, September 13, 2004 3:35 PM
> To: php-general@lists.php.net; M. Sokolewicz
> Subject: Re: [PHP] Convert textarea post data from plain text
> to html using php..how?
>
>
> From: "M. Sokolewicz" <tularis@php.net>
>
> >> 1. nl2br($posteddata) - This converts all the \r\n's to
> <br>'s so that
> >> it comes out with the same carriage returns as the person
> who inputed it
> >> gave it
> >
> > It doesn't change \r\n to <br>, it only changes \n to <br />
>
> It doesn't change anything, actually. It just inserts the <br />.
>
> <?php
> $str = "asdf\nasdf\nasdf\nasdf";
> $n = nl2br($str);
> if(strstr($n,"\n"))
> { echo 'Newlines present'; }
> else
> { echo 'Newlines not present'; }
> ?>
>
> ---John Holmes...