Wednesday, January 05, 2005

::PHP : Continue and Break (Basic) ::

Saper pernah belajar structured programming bender nie pun mmg berguner kat php..

continue......

tugas dier akan stop the loop pas tuh sambung balik klu value dier..
samer ngan condition di beri .. X paham e.g

while (list ($key, $value) = each ($arr)) {
if (!($key % 2)) { // skip odd members
continue;
}
do_something_odd ($value);
}

break
........

loop akan stop jiker meet the condition.. terus berhenti..
dier kuar dr loop Xpaham.. e.g

$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
\n";
}

nombor lima takkan kuar...

No comments: