我正在尝试使用此代码比较两个数组:
$diff = array_diff($selected, $checkboxes);
echo '<br>selected:';
print_r($selected);
echo '<br>original:';
print_r($checkboxes);
echo '<br>difference:';
print_r($diff);
奇怪的是,这导致以下结果:
selected:Array ( [0] => Forum1 [1] => Forum3 [2] => Furniture )
original:Array ( [0] => Forum1 [1] => Forum3 [2] => forum4 [3] => Furniture [4] => Nieuwforum )
difference:Array ( [0] => Forum1 [1] => Forum3 [2] => Furniture )
似乎array_diff函数只复制'selected'array。 我尝试了几个在类似问题中发布的东西,例如使用array_diff_assoc,但没关系。
任何人都知道出了什么问题?
答案 0 :(得分:1)
答案 1 :(得分:0)
我认为您正在搜索 array_intersect 。