Re: Carriage returns
| From: | Tyler BIRD | Date: | Fri, 18 Oct 2002 19:44:54 +0000 |
| Subject: | Re: Carriage returns | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-120554@lists.php.net to get a copy of this message | ||
Lets say your textarea has a name of comments then:
preg_replace("/(\r\n)/", "\n", $comments); # replaces all \r\n ( wintel
) to \n only
preg_replace("/\r/", "\n", $comments); # replaces all \r ( macintosh )
to \n only
Tyler
>>> "Stephen" <webmaster@melchior.us> 10/18/02 01:35PM >>>
Actually, what the user types in then goes out into an email. I'd have
to
switch the enters into \n but I'm not sure how...
----- Original Message -----
From: "Brent Baisley" <brent@landover.com.>
To: "Stephen" <webmaster@melchior.us>
Cc: "PHP List" <php-general@lists.php.net>
Sent: Friday, October 18, 2002 2:24 PM
Subject: Re: [PHP] Carriage returns
> You want to use addslashes before you store it in the database. When
you
> retrieve the data, you want to use removeslashes to convert things
back.
> If you are just going to display the submitted text as regular text
on a
> page, you want to use nl2br to convert the returns (new lines) to
and
> html <br />.
>
> On Friday, October 18, 2002, at 03:02 PM, Stephen wrote:
>
> > Hello,
> >
> > How can I make it so when a user types something in to a textarea,
when
> > they push enter, it stays as an enter? I've tried using a replace
> > function that replaces the ASCII code for enter to \n but that
didn't
> > work.
> >
> > Thanks,
> > Stephen Craton
> > http://www.melchior.us
> > http://php.melchior.us
> >
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology Environments
> p: 212.759.6400/800.759.0577
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php