foreachbreak.php
Result:
0=>10
1=>12
答案:能break!
continue test:
0=>10
1=>12
3=>25
答案:也能continue!
<?php
$i = array (10, 12, 13, 25);
foreach ($i as $key =>$value) {
if(13 == $value)
{
break;
}
echo $key."=>".$value."\n";
}
?>
$i = array (10, 12, 13, 25);
foreach ($i as $key =>$value) {
if(13 == $value)
{
break;
}
echo $key."=>".$value."\n";
}
?>
Result:
0=>10
1=>12
答案:能break!
continue test:
<?php
$i = array (10, 12, 13, 25);
foreach ($i as $key =>$value) {
if(13 == $value)
{
continue;
}
echo $key."=>".$value."\n";
}
?>
$i = array (10, 12, 13, 25);
foreach ($i as $key =>$value) {
if(13 == $value)
{
continue;
}
echo $key."=>".$value."\n";
}
?>
0=>10
1=>12
3=>25
答案:也能continue!
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/1705/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2009-4-10 10:30
评论列表