PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 5th, 2002, 02:28 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
replace enter with

okay, with my forum, i need it to replace an enter (line break) with a <br>, cause when its outputted, it ignores it otherwise. Anyone know how this would be done?

regards

Reply With Quote
  #2  
Old August 5th, 2002, 02:33 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: replace enter with

Check out the nl2br function

Reply With Quote
  #3  
Old August 5th, 2002, 04:08 PM
Micah Micah is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NC
Posts: 21 Micah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Micah
RE: replace enter with

Code:
$message = ereg_replace ( "rn", "<br>", $message);

Reply With Quote
  #4  
Old August 5th, 2002, 06:48 PM
sager sager is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 45 sager User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: replace enter with

or:
$mystring = "some stringn";
$mybrline = preg_replace("/n/", "n<br>", $mystring);

Reply With Quote
  #5  
Old August 5th, 2002, 08:20 PM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: replace enter with

How about:

$replaced_string = str_replace(chr(13).chr(10), "<br>", $string);

Reply With Quote
  #6  
Old August 5th, 2002, 09:08 PM
Micah Micah is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: NC
Posts: 21 Micah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Micah
RE: replace enter with

Actually you should do this:

$message = ereg_replace("(rn|n|r)", "<br>",
$message);

Because Macintosh uses "r", Unix uses "n", and Windows uses "rn".

Reply With Quote
  #7  
Old August 5th, 2002, 11:01 PM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
RE: replace enter with

This is the easiest way.

$stuff = ereg_replace(13,"<br>",$stuff);

Reply With Quote
  #8  
Old August 6th, 2002, 12:57 AM
EvilivE EvilivE is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Milwaukee, WI USA
Posts: 291 EvilivE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via Yahoo to EvilivE
RE: replace enter with

Who said there's only one way to skin a cat?

Reply With Quote
  #9  
Old August 6th, 2002, 01:20 AM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
RE: replace enter with

Thats ok to skin cats Just, please... No Cows.

Reply With Quote
  #10  
Old August 6th, 2002, 01:28 AM
postalcow postalcow is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Ford CIty, PA USA
Posts: 1,267 postalcow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to postalcow
RE: replace enter with

You can also reverse it. Say you are editing the lines they will display in the text box as <br> <br> so just reverse it as it comes in
$stuff = ereg_replace("<br>",13,$stuff);

Then reverse it again when you write the edit it.

PHP is proof that God loves us and wants us to be happy

Reply With Quote
  #11  
Old August 6th, 2002, 10:02 AM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: replace enter with

haha, jebus, so many things saying the same thing ;) i just used the nl2br() function, worked perfectly...

Reply With Quote
  #12  
Old August 6th, 2002, 01:40 PM
jorgen jorgen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Hardenberg, Holland<marquee>
Posts: 284 jorgen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: replace enter with

But there is not a function like br2nl only nl2br, so if you want to replace "<br>" with a carriage return you'll have to use ereg_replace

Reply With Quote
  #13  
Old August 6th, 2002, 02:03 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: replace enter with

holy crap jorgen, your signature or something is totally rootin up this forum.,..lol, the whole bottom half of the page is marquee'ing..lol

Reply With Quote
  #14  
Old August 6th, 2002, 02:11 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: replace enter with

haha, its fixed now

Reply With Quote
  #15  
Old August 7th, 2002, 09:16 AM
siteworkspro.com siteworkspro.com is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sydney, Australia
Posts: 92 siteworkspro.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to siteworkspro.com Send a message via AIM to siteworkspro.com
RE: replace enter with

darn, i wana c the scrolling text!

cos it goes round and round and round and round and round and round, boy im feeling dizzy and sick now

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > replace enter with


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 |