php in_array 等价多字节

php in_array multibyte equivalent

in_array() 函数在 php 多字节安全吗?

如果没有,我该怎么做呢?

php.net 多字节引用列表 mb_stristr() 但它接受字符串,而不是像 haystack 那样的 array .

我的 haystack = array 个字符串和 needle = string

因为我找不到任何内置的 PHP 解决方案,所以我按照@FirstOne 的建议做了。

/**
 * @return bool true if needle is found in haystack, false otherwise
 */
public function custom_mb_in_array($_needle, array $_hayStack) {
    foreach ($_hayStack as $value) {
        if (mb_strtolower($value) === mb_strtolower($_needle)) {
            return true;
        }
    }
    return false;   
}