How remove accents with PHP 7.4+
Aug 3, 2023
Sometimes we need to remove some characters from strings to use they like slugs or for other usages, so two of the possible solutions are Transliterator
$string = 'Ãéïòû';
$transliterator = Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
echo $normalized = $transliterator->transliterate($string);
it will output: Aeiou
another options is use Normalizer
$string = 'Ãéïòû';
$normalized = Normalizer::normalize($string, Normalizer::NFD);
echo preg_replace('/[\x{0300}-\x{036F}]/u', '', $normalized);
it will output: Aeiou
I hope it helps.