- htmlentities: documentation ( source)
- html_entity_decode: documentation ( source)
- preg_replace: documentation ( source)
<?php
function stripAccents($string) {
echo htmlentities($string, ENT_QUOTES, 'UTF-8');
return html_entity_decode(preg_replace('~&([A-Z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);~i', '$1', htmlentities($string, ENT_QUOTES, 'UTF-8')), ENT_QUOTES, 'UTF-8');
}
echo stripAccents('Âécho');