我试图只获取 array_search (false) 找不到的数组的键,但我对此没有任何想法......
现在我得到了找到的数组:
$ArrayA = ["Genre1" => 1, "Genre2" => 2, "Genre3" => 3, "Genre4" => 4];
$ArrayB = [1, 2, 3];
foreach ($ArrayB as $i) {
$found = array_search($i, $ArrayA);
if ($found === false) {
echo "$i is not in the array";
echo "list keys that are not in ArrayB";
} else {
echo "$i is in the array at <strong>$found</strong>";
}
}
但是正如我在标题中所说的那样,我需要打印在搜索中找不到的值的键......
任何想法如何获得这些密钥?...我知道如果找不到,搜索只会返回 false,有没有其他方法可以获取那些未找到的密钥而不是找到的密钥?
非常感谢!!!