I need help with the PHP replacement function I'm trying to create.
Basically, I want FYLLY to convert all special characters, such as á, é, í, ó, ú, ü, ñ, Á, É, Í, Ó, Ú, Ü, Ñetc a, e, i, o, u, u, n, A, E, I, O, U, U, N. : . The following explains why I say "FULLY convert."
Now I managed to do it only half using the following function:
function clean_url($text){
$text = preg_replace('~&([a-z]{1,10})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', htmlentities($text, ENT_QUOTES, 'UTF-8'));
return $text;
}
This at first glance gives me the desired result when viewing in MySQL or in a browser, so in PHP:
$string = "Ábalos";
echo clean_url($string);
Output source code HTML-page Abalos. It looks right at first glance.
But when I do
$string = "Ábalos";
echo htmlentities(clean_url(($string));
Output source code HTML-page AÂ?balos.
I want my function to be able to replace this part as well Â?. How can this be achieved?