String contains any items in an array (case insensitive)
Using the accepted answer:
$string = 'My nAmE is Tom.';$array = array("name","tom");if(0 < count(array_intersect(array_map('strtolower', explode(' ', $string)), $array))){ //do sth}
Just a side note that the if statement could be changed to:
if(0 < count(array_intersect(explode(' ', strtolower($string)), $array)))
since it's not really necessary to use array_map to apply strtolower
to each element. instead apply it to the initial string.