I need to skip certain part of the code if condition is true, How to do it in php
if ($a==0 && $b==0)
{
//skip this part of the code and exit loop
}
I need to skip certain part of the code if condition is true, How to do it in php
if ($a==0 && $b==0)
{
//skip this part of the code and exit loop
}
You can use break;
to exit from a loop.
Example:
<?php
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
while (list(, $val) = each($arr)) {
if ($val == 'stop') {
break; /* You could also write 'break 1;' here. */
}
echo "$val<br />
";
}