Re: what to use instead of foreach

From: Date: Tue, 14 Apr 2009 15:45:24 +0000
Subject: Re: what to use instead of foreach
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-291481@lists.php.net to get a copy of this message
2009/4/13 PJ <af.gourmet@videotron.ca>: > I have already tried with several count and for schemes. None work > because foreach ignores any counters once in the loop. Also, this > foreach is nested within another foreach; don't know if that affects > anything. Have you heard of while()? You can use it in combination with array_pop() and count() like: <? while (($data = array_pop($array)) !== NULL) { /* having $data and count($array) changes with every loop */ } ?> Bye

« previous php.general (#291481) next »