Removing special characters from the SQL result

390 views Asked by At

Let's say we have a string like:

$string = 'łłąśasłąśłąśóroduktu';

Basically, to replace all special characters i'm using the code below:

$new_string = iconv('utf-8','us-ascii//TRANSLIT//IGNORE', $string); 

And it works fine so result I get is like below:

llasaslaslasoroduktu

But, the problem is.. I have the same string in a database, I queried it (PDO prepare, and then fetch) and once i try to parse the result to iconv method above i get result like this:

asroduktu

So, in that case some letters are missing and were not replaced by it's clean version.

Table character set is currently set to utf8_general_ci. In 99% scenarios, these special characters comes from polish language.

How can i fix that with PHP?

0

There are 0 answers