Pedro Chagas
asked on
Doubts about endforeach
Hi E's, I use foreach for do cycles with arrays, and I want do like a break in foreach, in this case I discover endforeach in php.net.
My doubt about endforeach is what happening when I call endforeach, they finish all the cycle or just the key in that moment?
In practice if I have this array and this code:
1 => um
2 => dois
3 => tres
foreach($array as $element){
if ($element == "um"){
endforeach;
} else {
echo "do something";
}
}
My doubt is if the system run array [2] and [3] after endforeach (finish all cycle foreach or just for the moment that endforeach as call)?
Regards, JC
My doubt about endforeach is what happening when I call endforeach, they finish all the cycle or just the key in that moment?
In practice if I have this array and this code:
1 => um
2 => dois
3 => tres
foreach($array as $element){
if ($element == "um"){
endforeach;
} else {
echo "do something";
}
}
My doubt is if the system run array [2] and [3] after endforeach (finish all cycle foreach or just for the moment that endforeach as call)?
Regards, JC
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://php.net/manual/en/control-structures.alternative-syntax.php