![]() |
![]() |
![]() |
||||
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
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
quick php question
I am using the following code to echo a customers address from a mysql database:
<?php print $recipient->address_street ?> However, in the DB if there are 2 lines in the value, for example: 123 street Apt 1 and it will echo it like it is in the db with the double lines. How can I make it echo on just one line, preferably with a comma and space: 123 Street, Apt 1 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Industry Role:
Join Date: May 2011
Location: San Diego
Posts: 328
|
the address string probably has a newline in it or something
123 street Apt 1 is probably really something like 123 street\n\rApt 1, so maybe look into using preg_replace to replace \n or \n\r with ", " (maybe str_replace works for this too??). sorry maybe someone who knows php better will chime in with exact code for you ;] |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
that sounds like it could work, if anyone can provide the code to do that I will give it a try, also a code to end the preg replace since this value is the only exception
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Apr 2001
Posts: 1,738
|
<?php print nl2br($recipient->address_street) ?>
should do it for you ![]()
__________________
TeenFlood.com Online since 1998.
![]() TFCash KissMeGirl VirginRiches MondoBucks tim at tfcash.com or submit a ticket at our HelpDesk |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Jul 2008
Location: Los Angeles
Posts: 942
|
looks like you may need to update your function
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Apr 2001
Posts: 1,738
|
Sorry went back and re-read it, I thought it was printing on one line, and he wanted it to print on both
![]() <?php print str_replace('\\r\\n','', $recipient->address_street) ?> Got to stop pulling these all nighters!
__________________
TeenFlood.com Online since 1998.
![]() TFCash KissMeGirl VirginRiches MondoBucks tim at tfcash.com or submit a ticket at our HelpDesk |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
hmm the code seems like it would work but isn't make any difference, still echoing with the new line
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
got it working with this
![]() <?php print str_replace("\n",', ', $recipient->address_street) ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Confirmed User
Industry Role:
Join Date: Apr 2001
Posts: 1,738
|
Quote:
Can you look and see how it is listed in your database ?? Sometimes it's just a \n so then you'd use <?php print str_replace('\\n','', $recipient->address_street) ?>
__________________
TeenFlood.com Online since 1998.
![]() TFCash KissMeGirl VirginRiches MondoBucks tim at tfcash.com or submit a ticket at our HelpDesk |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Confirmed User
Industry Role:
Join Date: Apr 2001
Posts: 1,738
|
Quote:
![]()
__________________
TeenFlood.com Online since 1998.
![]() TFCash KissMeGirl VirginRiches MondoBucks tim at tfcash.com or submit a ticket at our HelpDesk |
|
![]() |
![]() ![]() ![]() ![]() ![]() |