General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 4th, 2003, 08:12 AM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 6
Send a message via AIM to jben.net
need simliar function to nl2br

Hi,

I need a similar function to nl2br, but I need it to REMOVE the nl in the text rather than keep them and add in <br> as well. eg:

my text has two lines, this is the first.
This is the second.

When I invoke nl2br on this text I get:

my text has two lines, this is the first.<br>
This is the second.

But what I want is:

my text has two lines, this is the first.<br>This is the second.

This is because I'm generating a XML doc with php from a mysql db and loading it into Flash MX, and it treats a nl in the text as 2 <br>'s, so I get doouble spaces, any ideas ???

Thanks in advance,

Jon

Reply With Quote
  #2  
Old July 4th, 2003, 11:46 AM
baines baines is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 33 baines User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 51 sec
Reputation Power: 7
How about......

PHP Code:
 $text=ereg_replace("\r","",$text);
$text=ereg_replace("\n","<br>",$text); 


Havn't tested it but I think it will do the trick.

Baines

Reply With Quote
  #3  
Old July 4th, 2003, 12:37 PM
jben.net jben.net is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 51 jben.net User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 41 sec
Reputation Power: 6
Send a message via AIM to jben.net
That's the ticket !

Hey man, thanks, you're a star ;-)

Cheers,

Jon

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > need simliar function to nl2br


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT