<?php function contains(string $haystack, array $needles){ $regex = '/' . str_replace('\|', '|', preg_quote(implode('|', $needles))) . '/i'; return preg_match($regex, $haystack); } $string = 'My nAmE is Tom.'; $array = array("name","tom"); if(contains($string,$array)) { echo 'doing action'; }
You have javascript disabled. You will not be able to edit any code.