Compare two string and ignore (but not replace) accents. PHP
One does not simply compare two strings...
Posted on November 5, 2019
## Convert accents to their non-accented counterpart and then compare strings.
$removeAccents=function(string$string){returnstrtolower(trim(preg_replace('~[^0-9a-z]+~i','-',preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i','$1',htmlentities($string,ENT_QUOTES,'UTF-8'))),' '));};$sentences=['depot','Dépôt','Depôt','Dépot','Depot','credit','Dépôt et créDit','Depôt et credit','Depot et~ CRÉDIT',];var_dump(array_map(function($sentence)use($removeAccents){return$removeAccents($sentence);},$sentences));