我的印象是 array_diff 评估两个数组中的值之间的差异。但不知何故它不起作用......我猜嵌套数组是这里的问题。显然 array_diff_assoc 不是解决方案,因为在这种情况下键无关紧要。
我什至不想让它嵌套,只是看看里面的值(在这种情况下是数组)是否相同。
$file_details = array(
array(
"uuid" => "45ebdbaa-380b-483b-80a2-73d7c53088e2",
"filename" => "train_failure.mp3",
),
array("uuid" => "97baa061-4208-4aeb-8136-eb76c0932a3d",
"filename" => "train_work1.mp3"
),
array("uuid" => "ksjdfls6-eb76c0932a3d",
"filename" => "train.mp3"
),
);
$items = array(
array(
"uuid" => "45ebdbaa-380b-483b-80a2-73d7c53088e2",
"filename" => "train_failure.mp3",
),
array(
"uuid" => "1233489eb76c0932a3d",
"filename" => "train.mp3"
),
);
print_r(array_diff($file_details,$items));
这将返回一个空数组...我应该如何解决这个问题?
我想要的输出是
array(
"uuid" => "97baa061-4208-4aeb-8136-eb76c0932a3d",
"filename" => "train_work1.mp3"
),
array(
"uuid" => "ksjdfls6-eb76c0932a3d",
"filename" => "train.mp3"
),
更新-:*我知道array_diff 不适用于一维数组,我很惊讶没有直接的 php 函数可以对多维数组进行比较。*