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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.