【发布时间】:2021-08-07 17:58:37
【问题描述】:
我需要找到第二个数组中不存在的数组的 ID,然后知道 ID。因此例如 eventid 将与 id 相同,我需要知道 id 是否存在于第二个数组中但它确实存在于第一个数组中。
所以 10001 = 10001, 10002 = 10002, 10003 = 10003, 10004 将在第一个数组中,但不在第二个数组中。如何获得 1004 不在第二个数组中的结果。
foreach($json as $eventinsert){
$eventid = $eventinsert['objectId'];
$event = new Google_Service_Calendar_Event(array(
'Id' => $eventinsert['objectId'],
'summary' => $eventinsert['name'],
'description' => $eventinsert['name'],
'start' => array(
'dateTime' => $eventinsert['dateStart']
),`enter code here`
'end' => array(
'dateTime' => $eventinsert['dateEnd']
)
));
foreach ($events as $event) {
$start = $event->start->dateTime;
$id = $event->id;
if (empty($start)) {
$start = $event->start->date;
}
// printf("%s (%s)\n", $event->getSummary(), $start);
// printf("%s (%s)\n", $event->getSummary(), $id);
}
【问题讨论】:
-
array_diff够用吗? -
听起来您只是想要 PHP 4 以来一直存在的array_diff 函数?
-
array_diff(): 参数 #2 不是 /var/www/html/corp/calsync/insert.php 中的数组
-
您告诉我们您有两个数组,但您的错误消息却另有说明。