Is in_array()
function in php multibyte safe?
If not ,how can i make it so?
The php.net multibyte reference lists mb_stristr()
but it accepts a string , not an array as haystack .
My haystack = array
of strings and needle = string
.
Since I could not find any built in PHP solution, I did as @FirstOne suggested.
/**
* @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;
}