i'm struggling with a function that adapts a text depending of the first letter of a string.
$str = "élo";
function deD($str) {
return (in_array(mb_strtolower($str[0]), array('a', 'e', 'é', 'è', 'ê', 'h', 'i', 'o', 'u')) ? 'd\'' : 'de ').$str;
}
echo deD($str).'</br>';
echo $str[0];
OUTPUT: de élo �
EXPECTED OUTPUT: d'élo é
Basically, mb_strtolower should prevent all special characters to be miss-read. I tried different options, but i still get it wrong. I'd like the function to work with all accent types.
Any idea ?
Thanks a lot from France !