2 回答
TA贡献1856条经验 获得超11个赞
如果您想通过单独检查每个值来获得结果,请尝试:-
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 )
TA贡献1783条经验 获得超4个赞
用javascript你可以写一个函数
function arrayDiff(x, y){
if(x==y){
return 1;
}
return 0;
}
像这样调用函数
var diff = arrayDiff(X[0], Y[0]);
据我所知,解决方案基于您的问题
- 2 回答
- 0 关注
- 87 浏览
添加回答
举报