1
我有一个包含一个位置 如 活动,纽约开发商一句如何检查一个字符串是否包含数组中的单词然后回显?
在我的数组我有位置
我要检查如果字符串包含从阵列中的位置,如果列表它然后回显出来
$string = 'Activities in New York for developers';
$array = array("New York","Seattle", "San Francisco");
if(0 == count(array_intersect(array_map('strtolower', explode(' ', $string)), $array))){
echo $location /*echo out location that is in the string on its own*/
} else {
/*do nothing*/
}
@martindrap:见我的编辑。 –