Skip to content

Instantly share code, notes, and snippets.

@swas
Created April 14, 2014 12:25
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swas/10643194 to your computer and use it in GitHub Desktop.
Save swas/10643194 to your computer and use it in GitHub Desktop.
PHP replacing special characters like à->a, è->e
// http://stackoverflow.com/questions/10152894/php-replacing-special-characters-like-a-a-e-e?answertab=votes#tab-top
// PHP.net User notes
<?php
$string = "ʿABBĀSĀBĀD";
echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $string);
// output: [nothing, and you get a notice]
echo iconv('UTF-8', 'ISO-8859-1//IGNORE', $string);
// output: ABBSBD
echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $string);
// output: ABBASABAD
// Yay! That's what I wanted!
?>
@dalsn
Copy link

dalsn commented May 9, 2016

Nice. Thanks for this!

@wapcrazut
Copy link

Still an useful trick! Thank you.

@manish-chaube
Copy link

The above code now gives � instead e.
is there any other option available ?

@Dmatrix-Armand-Niculescu

it fails for me, it removes the ẫ char
"key: FirstName | value: Vẫn Hon | processed: Vn Hon"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment