SV: [PHP] converting str with \n to one line str??
| From: | Jens Schodt | Date: | Tue, 21 Aug 2001 07:19:41 +0000 |
| Subject: | SV: [PHP] converting str with \n to one line str?? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-63639@lists.php.net to get a copy of this message | ||
nl2br is not working in this case. It does put a <br> with every new line,
but it does not remove the new line. The string will still have the line
changes and it will not work in Javascript.
Jens
-----Oprindelig meddelelse-----
Fra: Artwithin [mailto:gatha@artwithin.com]
Sendt: 20. august 2001 20:09
Til: Jens
Cc: php-general@lists.php.net
Emne: Re: [PHP] converting str with \n to one line str??
use nl2br()
http://www.php.net/nl2br
or, alternatively, use a regex to strip out the newlines
hope this helps.
----- Original Message -----
From: Jens <nice@email.dk>
To: <php-general@lists.php.net>
Sent: Monday, August 20, 2001 11:15
Subject: [PHP] converting str with \n to one line str??
> When I use Javascript with PHP i run into one problem. When I get the data
i
> need from the database it often has a lot of <br> and \n (new lines) in
it.
> The <br> are no problem when converting a string to a Javascript string,
but
> the \n are. The string has to be all in one line.
>
> example:
> <? $temp = "here
> I
> am"; ?>
>
> <script>var temp = <? echo $temp?> </script>
>
> This is not working!! But this would :
>
> <? $temp = "here I am"; ?>
>
> <script>var temp = '<? echo $temp?>'; </script>
>
> Can you help me please?
>
> thanks Jens
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>