呼唤远方
如果您想通过单独检查每个值来获得结果,请尝试:-function arrayDiff($x, $y){ return $x==$y ? 1 : 0;}$x = [ 0,1,1,0,1,0,0,0,0 ];$y = [ 0,0,1,0,1,0,0,0,0 ];$result=arrayDiff($x[0],$y[0]);print_r($result);//results : 1 in this case或者,如果您想要查询中提到的“数组形式”的结果,请尝试:-function myfunction($v1,$v2){ return $v1==$v2 ? 1 : 0;}$x = [ 0,1,1,0,1,0,0,0,0 ];$y = [ 0,0,1,0,1,0,0,0,0 ];print_r(array_map("myfunction",$x,$y));//results : Array ( [0] => 1 [1] => 0 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 1 [7] => 1 [8] => 1 )