如何在PHP中将单个数组与多维数组的一部分进行比较


How to compare single array to one part of multidimensional in PHP

我想从数据库中提取一列,并与单个数组进行比较。如果任何等于的值不打印,则打印单个数组的所有值。

尝试使用此

$array = array(); // Your array
$result = mysql_query("SELECT name FROM mytable");
$response = false;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
  if (in_array($row['name'], $array)) {
    $response = true;
  }
}
if ($response === false) {
    print_r($array);
}