Try using preg_grepwhich, as indicated in the manual:
Returns array entries matching pattern
Your code has been reworked to use it:
$array = array('Home', 'Design', 'Store');
$str = 'home';
if (preg_grep( "/" . $str . "/i" , $array)) {
die("Match");
} else {
die("No Match");
}
, - , array_map strtolower, in_array, :
$array = array('Home', 'Design', 'Store');
$str = 'home';
if (in_array(strtolower($str), array_map('strtolower', $array))) {
die("Match");
} else {
die("No Match");
}
: , preg_match , array_map, , . , . array_map.
- preg_grep: 2.9802322387695E-5 sec
- array_map: 1.3828277587891E-5 sec