Re: [PHP-DOC] foreach and break From: Egon Schmid ( <email protected>) (( <email protected>))
Date: 08/06/00

Ulf Wendel wrote:

> Ok Egon, this time I switched to the snaps:
> http://snaps.php.net/manual/en/html/control-structures.break.html. break
> seems to work for foreach() eigther, the manual does not mention this.

The manual at http://www.php.net/ was just updated by Rasmus.

> $array_data = array ( 1 => "one", 2 => "two", 3 => "three" );
> foreach($array_data as $value) {
> print "$value<br>";
> if ("one" == $value)
> break;
> }
>
> print "<hr>";
>
> foreach($array_data as $value) {
> print "level1, $value<br>";
> foreach($array_data as $key => $value) {
> print "level2, $value<br>";
> if ("one" == $value)
> break 2;
> }
> }

This example is now there and needs some beautifying.

-Egon

-- 
SIX Offene Systeme GmbH · Stuttgart  -  Berlin  -  New York
Sielminger Straße 63   ·    D-70771 Leinfelden-Echterdingen
Fon +49 711 9909164 · Fax +49 711 9909199 http://www.six.de