Jump to content

Replacing International Symbols with Standard ASCII for Shopping Cart


vozzek

Recommended Posts

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!

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.