Re: foreach

From: Date: Tue, 10 Oct 2006 18:26:10 +0000
Subject: Re: foreach
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-242916@lists.php.net to get a copy of this message
João Cândido de Souza Neto wrote:
Hello. In the follow code: $numbers=array(1,2,3,4,5); foreach ($numbers as number) {
    ...
} Inside foreach, could i know if i am in the last element of the array $numbers?
$last = end ( $numbers ); reset ( $numbers ); foreach ( $numbers as $number ) { if ( $number == $last ) { // last element ... } .... } -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 jnichel@dotcomholdingsofbuffalo.com

« previous php.general (#242916) next »