What is the difference between break and continue in PHP?
break used to get out from the loop statement, but continue just stop script on specific condition and then continue looping statement until reach the end..
for($i=0; $i<10; $i++){
if($i == 5){
echo "It reach five
";
continue;
}
echo $i . "
";
}
echo "
";
for($i=0; $i<10; $i++){
if($i == 5){
echo "It reach end
";
break;
}
echo $i . "
";
}
Hope it can help u;