![]() |
![]() |
![]() |
||||
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. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
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.
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed IT Professional
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
|
$addressfield = $street . '\n' . $city . '\n' . $etc;
__________________
The Best Affiliate Software, Ever. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Do Fun Shit.
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 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Macdaddy coder
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
|
use "\n\r" or "\r"
not sure. ![]()
__________________
MacDaddy Coder. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Confirmed IT Professional
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
|
Quote:
Code:
function br2nl($text) { $text = str_replace("<br />","",$text); $text = str_replace("<br>","",$text); return $text; }
__________________
The Best Affiliate Software, Ever. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Macdaddy coder
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
|
try this
$addressfield = $street . "\r" . $city . "\r";
__________________
MacDaddy Coder. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
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
![]()
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Join Date: May 2006
Location: Never never land
Posts: 470
|
That did it - \r
![]()
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Macdaddy coder
Industry Role:
Join Date: Feb 2002
Location: MacDaddy pimp coder
Posts: 2,806
|
Quote:
You are welcome ![]()
__________________
MacDaddy Coder. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Confirmed User
Join Date: May 2006
Location: Never never land
Posts: 470
|
Quote:
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 ![]()
__________________
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |