这里有两个数组
$one = array("engineering", "applied", "mathematics");
$se = "Applied mathematics is a branch of mathematics that concerns itself with mathematical methods that are typically used in science, engineering, business, and industry.";
$two = explode(' ', $se);
if (//those 3 values from $one exist in $two) {
echo "i got it!";
} else {
echo "you dint get :(";
}
我正在研究这个,但我没有找到任何简单的答案。你能帮我吗?
您可以使用array_intersect来检查一个数组中的值是否存在于两个数组中,如果您得到相同的数组作为结果,则您知道它们存在于两个数组中。
尝试array_intersect
:
if ( array_intersect( $one, $two ) ) {
// arrays share one or more terms
}
你可能应该strtolower($se)
,因为相交测试是===
。