Line Breaks

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cookie-Monster
Forum Newbie
Posts: 2
Joined: Mon May 05, 2003 10:46 am
Location: Germany
Contact:

Line Breaks

Post by Cookie-Monster »

I have a problem with the breaking of the lines. I hope that it is called like this in english. I do not mean word wrap but the pressing of Return.

A tried to implement phpBB into my website. and therefore wnated announcements of the board as news on my page. I managed to do that. Wasn't so difficult.

But please feel free to have a look at my problem. The news section is here: http://www.starfall.de

The post on the board is here: http://board.starfall.de/viewtopic.php?t=285

And I want the news to look exactly like the topic, but as you can see it doesn't and I do not have the slightest idea why.

Could you help me?

thx Cookie
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

Cookie-Monster
Forum Newbie
Posts: 2
Joined: Mon May 05, 2003 10:46 am
Location: Germany
Contact:

Post by Cookie-Monster »

That was a good idea. I also discovered another method of doing it:

$message = str_replace("\n", "\n<br />\n", $message);

Wonder why I didn't do it like this in the first way.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Cookie-Monster wrote:That was a good idea. I also discovered another method of doing it:

$message = str_replace("\n", "\n<br />\n", $message);

Wonder why I didn't do it like this in the first way.
It's probably preferable to use nl2br() as it does exactly what the str_replace() snippet you posted above does.

Mac
Post Reply