【发布时间】:2012-12-09 00:04:32
【问题描述】:
尝试匹配两个数组中的值,如果存在匹配的值,则输出 true,可能是 array_intersect 函数?很不确定!任何帮助深表感谢!
基本上有两个我不能完全放入这个框的 sql 查询!但它们每个都返回一个数组 $staffExpertise 和 $moduleExpertise,但我对 php 非常陌生,对数组相交函数更加不熟悉,所以不太确定从这里做什么!
foreach ($results as $row) {
$staffExpertise = $row['expertise'];
}
foreach ($results as $row) {
$moduleExpertise = $row['expertise'];
}
$arrayIntersection = array_intersect($moduleExpertise, $staffExpertise);
if($arrayIntersection = ){
}
【问题讨论】:
-
基本上有两个我不能完全放入这个盒子的 sql 查询!但他们每个人都返回一个数组 $staffExpertise 和 $moduleExpertise,但我对 php 很陌生,对数组相交函数更不熟悉,所以不太确定从这里做什么! foreach ($results as $row) { $staffExpertise = $row['expertise']; } foreach ($results as $row) { $moduleExpertise = $row['expertise']; } $arrayIntersection = array_intersect($moduleExpertise, $staffExpertise); if($arrayIntersection = ){ }
-
@FindlayMack 使用正确的格式更新您的问题。
-
向我们展示您尝试的一些代码,否则我们无能为力。
-
哦,编辑你的问题而不是在 cmets 中发布代码,它读起来很糟糕!
-
@FindlayMack:为什么有两个 SQL 查询?为什么不是
INNER JOIN?
标签: php arrays intersect array-intersect