Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-22-2006, 12:50 PM   #1
Big John
Confirmed User
 
Join Date: May 2006
Location: Never never land
Posts: 470
A Quick PHP Question...

I need to combine some strings and send them to a page with a multi-line form field in it (hope that makes sense). In itself this is simple and so's the problem...

I want to insert a line break betweek each bit of data (it's an address field and I want each piece on its own line). How to do it? Obviously being an form field <br \> won't work so what do I use? Is there an escape character?

for example I want:

$ addressfield = $ street . (new line) . $ city . (newline) etc

I figure someone here must know how to do something so simple. It's such a daft thing to not know how to do that finding how is proving impossible.
__________________
Big John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 12:52 PM   #2
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
$addressfield = $street . '\n' . $city . '\n' . $etc;
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 12:55 PM   #3
munki
Do Fun Shit.
 
munki's Avatar
 
Industry Role:
Join Date: Dec 2004
Location: OC
Posts: 13,393
I think this is what you are looking for, or at least close.

http://us2.php.net/manual/en/function.nl2br.php
__________________

I have the simplest tastes. I am always satisfied with the best.” -Oscar Wilde
munki is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 12:56 PM   #4
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
use "\n\r" or "\r"

not sure.
__________________
MacDaddy Coder.
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 12:58 PM   #5
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
Quote:
Originally Posted by munki
I think this is what you are looking for, or at least close.

http://us2.php.net/manual/en/function.nl2br.php
Actually he's looking to do the opposite. Here's a bit of code I found years ago that does the trick if you need to convert <br> tags to the newline char...
Code:
function br2nl($text) {
   $text = str_replace("<br />","",$text);
   $text = str_replace("<br>","",$text);
   return $text;
}
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 01:01 PM   #6
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
a newline char is \r in a multiline textfield like textarea .
__________________
MacDaddy Coder.
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 01:02 PM   #7
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
try this

$addressfield = $street . "\r" . $city . "\r";
__________________
MacDaddy Coder.
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 01:02 PM   #8
Big John
Confirmed User
 
Join Date: May 2006
Location: Never never land
Posts: 470
\n wasn't working for some odd reason. Hmmm...thanks for the replies. I'll try combining it with r as suggested
__________________
Big John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 01:08 PM   #9
Big John
Confirmed User
 
Join Date: May 2006
Location: Never never land
Posts: 470
That did it - \r
__________________
Big John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 01:09 PM   #10
boldy
Macdaddy coder
 
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
Quote:
Originally Posted by Big John
That did it - \r

You are welcome
__________________
MacDaddy Coder.
boldy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-22-2006, 01:31 PM   #11
Big John
Confirmed User
 
Join Date: May 2006
Location: Never never land
Posts: 470
Quote:
Originally Posted by boldy
a newline char is \r in a multiline textfield like textarea .

You'd be amazed how hard it is to find that little bit of info. I found quite a few pages listings various escape characters etc that missed out the /r. Oh well - now I know and won;t forget. Thanks again
__________________
Big John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.