| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Adding Line Breaks; Easy way with PHP? | |
|---|---|
| Tweet Topic Started: Jun 26 2005, 08:41 PM (450 Views) | |
| Dennis | Jun 26 2005, 08:41 PM Post #1 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
What is the easiest way to automagically(tm) add <br /> tags to each line break? i.e. A user types a comment, and clicks enter, for a line break. Then when the comment is added, it automatically replaces the break with a <br /> tag. |
![]() |
|
| FearKiller | Jun 26 2005, 10:04 PM Post #2 |
|
www.drewscripts.com
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
|
![]() |
|
| James | Jun 27 2005, 04:09 AM Post #3 |
|
Live to Dream
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Wow. And i've been doing str_replace's on \n and \r\n for ages
|
![]() |
|
| FearKiller | Jun 27 2005, 03:46 PM Post #4 |
|
www.drewscripts.com
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Although that function exists I don't use it either. This is what I use to take care of line breaks.
This better helps to prevent abuse as it stops users from putting multiple line breaks and creating large blank messages.
|
![]() |
|
| Jeremy | Jun 27 2005, 06:44 PM Post #5 |
![]()
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Depending on what you code for, that's the better method...
That's what I use. If you need something to prevent multiple line breaks, there's an easier regular expression than what FearKiller mentioned, but I won't get into that, here.
|
![]() |
|
| Dennis | Jun 27 2005, 07:06 PM Post #6 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
@FK: I'll definitely use that, but in this case, it's only for a site news script, so I'm not really worried about people abusing it. So the nl2br function works for now. |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
6:34 AM Jul 11
|



![]](../../../../0/1/0/p601690/pipright.png)




6:34 AM Jul 11