Getting line breaks to work?

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
Gappa
Forum Contributor
Posts: 119
Joined: Fri May 23, 2003 10:02 am

Getting line breaks to work?

Post by Gappa »

Hey all, I got a piece of code going along, much to the help of people here such as volka hehe... but yeah, it access a database (shared with phpbb) grabs some text, (post_text) now (hopefully one of) my problem(s) is that line breaks arnt happening or return, what ever you would like to call them... do these need to be enable some how??
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

I'm not realy sure what you asking, but i think you need nl2br
Gappa
Forum Contributor
Posts: 119
Joined: Fri May 23, 2003 10:02 am

Post by Gappa »

Hmm well im using phpbb, same forum as this and when you type into these textboxes and you press ENTER it doesnt place like <br>

but still when you view it has the line breaks...

Gah its hard to explain sorry... this nl2br , might be what im after but not sure
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Definitely sounds like you need nl2br() - it adds HTML line breaks (<br />s) alongside new line characters (which are what are inserted when you press enter in a text field).

Mac
Gappa
Forum Contributor
Posts: 119
Joined: Fri May 23, 2003 10:02 am

Post by Gappa »

Ahh ok, hmm reading the manual part on using nl2br didnt tell me alot about actually using it in my script, hmm forgive my newbness, but a lil help in how to if possible?

I want tp apply it to this section of my script:

Code: Select all

<?php echo $row['post_text']; ?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Just use it on the variable like so:

Code: Select all

<?php echo nl2br($row['post_text']); ?>
Don't worry about being new to this, we all had to start somewhere.

Mac
Gappa
Forum Contributor
Posts: 119
Joined: Fri May 23, 2003 10:02 am

Post by Gappa »

Cheers, mac, i think i kinda jumped the gun, i got 3 weeks of holidays now so i think i will try teach myself in a more structured way, rather than just doign this and that....

thanks again :)
Post Reply