假设有两个数组$a[0],$a[1],$a[2]和$b[0],$b[1],$b[2]//===========判断块开始
先是对$a[0]和$b[0]的大小判断,如果为true,结束所有判断,跳到another code brick;
如果为false
去判断$a[1]和$b[1]的大小,如果为true,结束所有判断,跳到another code brick;
如果为false,那么
最后判断$a[2]和$b[2]的大小,结束判断
//===========判断块结束
another code brick;请问难道这种应该用不断的if嵌套么?
如果不是,那么应该怎样实现?
先是对$a[0]和$b[0]的大小判断,如果为true,结束所有判断,跳到another code brick;
如果为false
去判断$a[1]和$b[1]的大小,如果为true,结束所有判断,跳到another code brick;
如果为false,那么
最后判断$a[2]和$b[2]的大小,结束判断
//===========判断块结束
another code brick;请问难道这种应该用不断的if嵌套么?
如果不是,那么应该怎样实现?
echo 1;
}
function f2(){
echo 2;
}
$fns=Array(f1,f2);
$a= Array(3,2);
$b=Array(2,3);
foreach($a as $k => $v )
if( $v > $b[$k] ) $fns[$k]();
$k = 1;
if($a[$i] == $b[$i]) break;
$k = 0;
}
if($k) {
another code brick;
}
function comp($n, $m)
{
if ($n ==$m) return True;
else return False;
}
$c = array_map("comp", $a, $b);
if (count(array_intersect($c, array(True))) > 0){
another code brick;
}
?> 不过这个要走完全部单元,可以说不符合你的题意
但你可以留着参考,在其他必须全部判断的时候还是有用的