Reputation: 392
I have this:
$var = "User_èéàùìò";
if(0 < count(array_intersect(array_map("strtolower", str_split($var)), array("ì", "è", "é", "ò", "à"))))
echo "true"; else echo "false";
This returns "false". What am i supposed to do?
Upvotes: 1
Views: 122
Reputation: 15464
You know that php string function actually work with binary data but not with text. Encoding of your text is UTF8. So you cannot use str_split
on it.
$var = "User_èéàùìò"; // has 11 characters
str_split($var); // has 17 items
Better to use regular expressions which support multibyte characters.
$var = "User_èéàùìò";
var_dump(preg_match('/[ìèéòà]/iu', $var)); // i - case insensitive, u - utf character
Upvotes: 1