PHP case and accent insensitive search into an array -


I have an array in words, some of them are with letters, I want to test that a given word That is in the array, but this case is making and is insensitive for example:

  array = array ("coche", "camión", "moto", "carro");   

I want a simple little function, like some in_array . If my string is 'camion' or 'camine' , then it should return true .

Any thoughts?

Try it: :-D

  function check_array ($ array , $ String) {$ trans = array ("", "e", "e", "& eacute;" = & gt; "e", "and aacute;" = => "one", " = "I", "ó" => "O", "&"; "="; "A", "& iacute;" = & gt; "I", "A" => Amp; oacute; "= & gt;" O "," & Amp; uacute; "= & gt;" U "," º "= & gt;" U "," and OUl; "=> "," ¼ "=>" U "); $ RealString = strtr ($ string, $ trans); Forex Currency (dollar array as dollar) {$ realVal = strtr ($ val, $ trans); If (strcasecmp ($ realwall, $ true string) == 0) {back true; } } return false; }   

To use this:

  check_array ($ array, 'camion');   

According to the suggestion, use of strcasecmp

Comments