我认为您要问的可以解释为:
"列出所有包含在$area
数组中找到的字符串实例的 $address 字符串。 "
在这种情况下:
// Set up.
$address = array(
"This Street, Nice Area, That Country",
"This Street, Superb Area, Which Country",
"This Street, Fine Area, A Country",
);
$area = array("Nice", "Good");
// The search.
$results = array();
foreach ($address as $haystack) {
foreach ($area as $needle) {
$regexPattern = "#{$needle}#";
if (preg_match($regexPattern, $haystack))
array_push($results, $haystack);
}
}
// The results.
foreach ($results as $result) {
echo "<p>{$result}</p>";
}