If you use this function on a unicode string without telling PHP that it is unicode, then you will corrupt your string. In particular, the uppercase 'A' with tilde, common in 2-byte UTF-8 characters, is converted to lowercase 'a' with tilde.
This can be handled correctly by:
$str = mb_strtolower($str, mb_detect_encoding($str));
Or if you know your data is UTF-8, just use the string "UTF-8" as the second argument.
You should check also that mb_detect_encoding() is checking the encodings you want it to check, and is detecting the correct encodings.