use nl2br()
http://www.php.net/nl2br
or, alternatively, use a regex to strip out the newlines
hope this helps.
----- Original Message -----
From: Jens <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]