Re: end of array

From: Date: Sat, 22 Jan 2005 14:14:12 +0000
Subject: Re: end of array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-207040@lists.php.net to get a copy of this message
Jeffery Fernandez <forums@jefferyfernandez.id.au> writes: > Hi all, > > I have a foreach loop on an array and within that loop I need to find > if the array has reached the last pointer. I have tried > > if (next($row)) > { > > } > > but that advances the pointer. Any tips on finding out if the array > pointer has reached the last element ? $n_elts = count($myarray); for ($i=0; $i< $n_elts ; $i++) { if ($i = $n_elts -1) { echo "On last element"; break; } else { echo "Somwhere in the middle"; } }

« previous php.general (#207040) next »