PHP 中的 SQL 是否有等效的 NOT IN 运算符?if(count($result1) > 0) { $query_transline_conflict = "SELECT * FROM transaction_line as tl LEFT JOIN transaction as t ON tl.transaction_id = t.transaction_id LEFT JOIN resources as r ON tl.resource_id = r.resource_id WHERE t.equipment_class_id = '$equipment_class_id' AND tl.returned = '0'"; $result_transline_conflict = mysqli_query($conn, $query_transline_conflict); $result2 = mysqli_fetch_all($result_transline_conflict,MYSQLI_ASSOC); $x = 0; foreach($result2 as $row){ $already_booked_range = getDatesFromRange($row['start_date'],$row['end_date']); $new_array_already_booked[$x] = $already_booked_range; $x++; }我有一个正在输入的 start_date 和 end_date。现在$new_array_already_booked存储将被比较的日期范围。所以我想使用 NOT IN 运算符来比较 php。我希望我说得通。仍然是初学者并试图学习。Array([0] => Array ( [0] => 2019-07-25 [1] => 2019-07-26 [2] => 2019-07-27 )[1] => Array ( [0] => 2019-07-30 [1] => 2019-07-31 [2] => 2019-08-01 ))
2 回答
湖上湖
TA贡献2003条经验 获得超2个赞
如果要检查一个数组的任何元素是否在另一个数组中,可以使用array_intersect:
$a = Array('bird', 'butterfly', 'bat');
$b = Array('ball', 'helmet', 'bat');
if (!array_intersect($a, $b)) echo 'not in';
- 2 回答
- 0 关注
- 96 浏览
添加回答
举报
0/150
提交
取消