Link to home
Start Free TrialLog in
Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal

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



ASKER CERTIFIED SOLUTION
Avatar of Roger Baklund
Roger Baklund
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Heh, that link was to the russian version of the php manual, but the text on that page is currently in english... for future reference, this is the english version:

http://php.net/manual/en/control-structures.alternative-syntax.php
SOLUTION
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial