这是我的数组
(
"userServiceIds": "1,2,3",
"enggServiceIds": "4,5,6,2,1"
)
因为"userServiceIds"
必须与"enggServiceIds"
进行交叉检查,"enggServiceIds"
必须与"userServiceIds"
交叉检查
因为OUTPUT只需要
"userServiceIds": "1,2,3"
"enggServiceIds": "4,5,6"
答案 0 :(得分:3)
也许您正在寻找array_diff
。
$data = [
'userServiceIds' => [1,2,3],
'enggServiceIds' => [4,5,6,2,1]
];
$data['enggServiceIds'] = array_diff($data['enggServiceIds'], $data['userServiceIds']);