我有这两个数组:
$variables = [
'color' => 'red',
'width' => 100,
'height' => 50
];
extract($variables);
echo 'Color: ' . $color;
echo 'Size: ' . $width . 'x' . $height;
我需要一个php函数来将两者结合起来,结果如下:
Array ( [291] => 3 [292] => 1 [293] => 3 )
Array ( [291] => 3 [292] => 1 )
我该怎么办?
答案 0 :(得分:0)
似乎您要计算array_difference,应该使用array_diff
<?php
$a1=array ( "291" => 3, "292" => 1, "293" => 3 );
$a2=array ( "291" => 3, "292" => 1 ) ;
$result=array_diff_assoc($a1,$a2);
print_r($result);
?>