PHP语言怎么跳出两个for循环

来源:百度知道 编辑:UC知道 时间:2024/06/27 07:00:55
当第一个for语句里$i=3,第二个for语句里$j=2时if语句不满足,此时我想跳出第二个for,怎么跳出?我用的else 里的break根本就没有用!
<?php
function longest_common_sequence($input, &$longest_sequence)
{
$n = count($input);
for($j = 0;$j < $n-1;$j++) /* find the shortest string */
{
for($i = $j + 1;$i < $n;$i++)
{
if (strlen($input[$i]) < strlen($input[$j]))
{
$temp = $input[$i];
$input[$i] = $input[$j];
$input[$j] = $temp;
} else continue;
}
}
print_r($input);
$Min_len = $input[0];
$m = strlen($Min_len);
for($i = 1;$i < $n;$i++)
{
for($j=1;$j<=$m;$j++)
{
if (strstr($input[$i], substr($Min_len, 0, $j)))
{$common_sequence=substr($Min_len, 0, $j);

}
else break;
} echo $common_sequence;
echo "<br />";

}
}
$str

$input[$j] = $temp;
改成
$input[$j] = $temp;$i=9999;$j=9999;

continue 2;
break 2;

for($i = 1;$i < $n;$i++){
$break = false;
for($j=1;$j<=$m;$j++){
if (strstr($input[$i], substr($Min_len, 0, $j))){
$common_sequence=substr($Min_len, 0, $j);
}else{
$break = true;
break;
}
}
if($break) break;
echo $common_sequence;
echo "<br />";
}

$input[$j] = $temp;
改成
$input[$j] = $temp;$i=9999;$j=9999;

goto语句