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 03-26-2014, 01:42 PM   #1
mkx
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

Last edited by mkx; 03-26-2014 at 01:43 PM..
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 02:23 PM   #2
nm_
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 ;]
nm_ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 02:27 PM   #3
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 03:00 PM   #4
TFCash
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
TFCash is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 03:09 PM   #5
KickAssJesse
Confirmed User
 
KickAssJesse's Avatar
 
Industry Role:
Join Date: Jul 2008
Location: Los Angeles
Posts: 942
looks like you may need to update your function
__________________

Contact - email: jesse~AT~atkcash~DOT~com - Skype: kickassjesse - ICQ: 386185547
ATK Cash $$$
KickAssJesse is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 03:19 PM   #6
TFCash
Confirmed User
 
Industry Role:
Join Date: Apr 2001
Posts: 1,738
Quote:
Originally Posted by KickAssJesse View Post
looks like you may need to update your function
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

Last edited by TFCash; 03-26-2014 at 03:20 PM..
TFCash is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 03:33 PM   #7
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 03:42 PM   #8
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
got it working with this thanks a bunch!

<?php print str_replace("\n",', ', $recipient->address_street) ?>
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 03:43 PM   #9
TFCash
Confirmed User
 
Industry Role:
Join Date: Apr 2001
Posts: 1,738
Quote:
Originally Posted by mkx View Post
hmm the code seems like it would work but isn't make any difference, still echoing with the new line

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
TFCash is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-26-2014, 03:44 PM   #10
TFCash
Confirmed User
 
Industry Role:
Join Date: Apr 2001
Posts: 1,738
Quote:
Originally Posted by mkx View Post
got it working with this thanks a bunch!

<?php print str_replace("\n",', ', $recipient->address_street) ?>
Glad to hear it
__________________
TeenFlood.com Online since 1998.

TFCash KissMeGirl
VirginRiches MondoBucks

tim at tfcash.com or submit a ticket at our HelpDesk
TFCash 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.