For more information, see the implementation of an algorithm. nested judgment involves two arrays: $ a [0], $ a [1], $ a [2], and $ B [0]. $ B [1], $ B [2] starts to judge the block size first. if it is true, all judgments are ended, jump to another & nbsp; code & nbsp; brick; if it is false, judge the size of $ a [1] and $ B [1]. if it is tr, ask you for an algorithm implementation, nested judgment
Suppose there are two arrays $ a [0], $ a [1], $ a [2], and $ B [0], $ B [1], $ B [2]
// ============= Determine the start of a block
First, judge the size of $ a [0] and $ B [0]. if it is true, end all judgments and jump to another code brick;
If it is false
Determine the size of $ a [1] and $ B [1]. if it is true, end all judgments and jump to another code brick;
If it is false
Determine the size of $ a [2] and $ B [2], and end the judgment.
// ============== Judge the block end
Another code brick;
Is it necessary to use continuous if nesting?
If not, how should we implement it?
------ Solution --------------------
Method functions are managed using arrays, and arrays are judged cyclically. functions are selected based on subscripts.
function f1(){
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]();
------ Solution --------------------
For ($ I = 0; $ I $ K = 1;
If ($ a [$ I] ==$ B [$ I]) break;
$ K = 0;
}
If ($ k ){
Another code brick;
}
------ Solution --------------------
You feel like a post that was asked not long ago to judge the submitted content one by one, but that is to end the judgment when false is met.
Another idea:
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;
}
?>
However, if you want to finish all the units, it may not match your question.
However, you can keep the reference, which is useful when all others must be judged.