vozzek Posted January 3, 2010 Share Posted January 3, 2010 Hi all, I've got a self-made php-based shopping cart that's working great, but I'm recently having trouble because I'm now allowing customers to enter international names and addresses. My database allows the entry of special international characters (example: í, è, ó, â, é, ñ, etc...), but when I try to pass these names and addresses through my payment gateway, my merchant provider kicks back an error. I'd like to strip these characters and replace them with standard letters before sending the data through the gateway. Are there any existing php routines that do this? What's the best way you guys would recommend me handling the issue? As always, thanks in advance for the help! Quote Link to comment https://forums.phpfreaks.com/topic/187027-replacing-international-symbols-with-standard-ascii-for-shopping-cart/ Share on other sites More sharing options...
vozzek Posted January 4, 2010 Author Share Posted January 4, 2010 Anyone have an idea? Or a list of international symbols so I can do a string replace? Quote Link to comment https://forums.phpfreaks.com/topic/187027-replacing-international-symbols-with-standard-ascii-for-shopping-cart/#findComment-988142 Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 http://www.randomsequence.com/articles/removing-accented-utf-8-characters-with-php/ Quote Link to comment https://forums.phpfreaks.com/topic/187027-replacing-international-symbols-with-standard-ascii-for-shopping-cart/#findComment-988146 Share on other sites More sharing options...
vozzek Posted January 4, 2010 Author Share Posted January 4, 2010 Yikes! Jay, that was astonishingly easy and helpful. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/187027-replacing-international-symbols-with-standard-ascii-for-shopping-cart/#findComment-988169 Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 Don't thank me, thank google http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=how+to+replace+international+characters+php Quote Link to comment https://forums.phpfreaks.com/topic/187027-replacing-international-symbols-with-standard-ascii-for-shopping-cart/#findComment-988173 Share on other sites More sharing options...
vozzek Posted January 4, 2010 Author Share Posted January 4, 2010 Hmmm... Okay, I've modified the code slightly (I need to change variables, not the URL) and here's what I have: <?php $search = explode(",","ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u"); $replace = explode(",","c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u"); $first_name = str_replace($search, $replace, $first_name); $last_name = str_replace($search, $replace, $last_name); $address_1 = str_replace($search, $replace, $address_1); $address_2 = str_replace($search, $replace, $address_2); $city = str_replace($search, $replace, $city); ?> Admittedly I'm inexperienced with the whole explode thing, but this isn't working... the variables still contain the internation characters. How come? Quote Link to comment https://forums.phpfreaks.com/topic/187027-replacing-international-symbols-with-standard-ascii-for-shopping-cart/#findComment-988313 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.