New lines to <br>

New lines to <br>

am 08.10.2007 10:56:32 von vincent.marguerit

Hello !

How to delete all the new lines and replace them by
, because new
lines involves Javacript Error, IE:

facts_infos[0][1] = "In 1972 he was done for murdering a colleague
over a matter of $30!

He served 2 years for this and was never seen again, blah blah blah."

What I do is:
nl2br($row['facts_content']))

This add a
but does not delete the new line before "He served".

Does anyone know how to replace new lines to
tags and delete new
lines \n ?

Thanks,
Vincent.

Re: New lines to <br>

am 08.10.2007 11:11:44 von Lars Eighner

In our last episode,
<1191833792.306121.298110@19g2000hsx.googlegroups.com>,
the lovely and talented Defacta
broadcast on comp.lang.php:

> Hello !

> How to delete all the new lines and replace them by
, because new
> lines involves Javacript Error, IE:

> facts_infos[0][1] = "In 1972 he was done for murdering a colleague
> over a matter of $30!

> He served 2 years for this and was never seen again, blah blah blah."

> What I do is:
> nl2br($row['facts_content']))

> This add a
but does not delete the new line before "He served".

Exactly as the manual describes nl2br. You did read the manual, didn't you?

> Does anyone know how to replace new lines to
tags and delete new
> lines \n ?

I guess you will have to settle for the obvious way: str_replace.

RTFM.

--
Lars Eighner
Countdown: 470 days to go.
What do you do when you're debranded?

Re: New lines to <br>

am 08.10.2007 11:17:10 von vincent.marguerit

On 8 oct, 10:11, Lars Eighner wrote:
> In our last episode,
> <1191833792.306121.298...@19g2000hsx.googlegroups.com>,
> the lovely and talented Defacta
> broadcast on comp.lang.php:
>
> > Hello !
> > How to delete all the new lines and replace them by
, because new
> > lines involves Javacript Error, IE:
> > facts_infos[0][1] = "In 1972 he was done for murdering a colleague
> > over a matter of $30!

> > He served 2 years for this and was never seen again, blah blah blah."
> > What I do is:
> > nl2br($row['facts_content']))
> > This add a
but does not delete the new line before "He served".
>
> Exactly as the manual describes nl2br. You did read the manual, didn't you?
>
> > Does anyone know how to replace new lines to
tags and delete new
> > lines \n ?
>
> I guess you will have to settle for the obvious way: str_replace.
>
> RTFM.
>
> --
> Lars Eighner
> Countdown: 470 days to go.
> What do you do when you're debranded?

Yes but when I try this:
str_replace("\n", "
", ($row['facts_content'])) ;

I get the following:
facts_infos[0][1] = "In 1972 he was done for murdering a colleague
over a matter of $30!

He served 2 years for this and was never seen again, blah blah
blah."

So I don't what I could do...