Convert Accented Characters

PHOTO EMBED

Wed Jun 24 2020 09:51:02 GMT+0000 (UTC)

Saved by @Amna #php

function replace_accents($str) {
   $str = htmlentities($str, ENT_COMPAT, "UTF-8");
   $str = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str);
   return html_entity_decode($str);
}
content_copyCOPY

For instance, if you want to use a string as part of a URL but need to make it safe for that kind of use.

https://css-tricks.com/snippets/php/convert-accented-characters/