-5]+/u', '', $str); …and here’s my sources and #2." />
Programmed Under The Influence
Removing Non-English Characters in PHP

Why would you want to do this, you say?

Well, I found out the other day a payment processor we use (Authorize.net) at the company I work at doesn’t allow for non-english characters and in return, throws a cryptic error.

Here’s the error:
E00003 - Invalid character in the given encoding. Line 15, position 54.

Here’s the trick:
$str = preg_replace('/[^\00-\255]+/u', '', $str);


…and here’s my sources and #2.

  1. skrolikowski posted this