Re: assoc array question

From: Date: Thu, 15 Aug 2002 21:52:28 +0000
Subject: Re: assoc array question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112867@lists.php.net to get a copy of this message
Perhaps something like... $i = 1; while (list($key, $val) = each($info)) { if ($i == 1 || $i == count($info)) doThis; else doThat; ++$i; } ? J Alexander Ross wrote: > I have this: (note that $info is an Assoc Array > > while (list ($key, $val) = each ($info)) > { > do stuff > } > > I would like to do slightly different stuff if I'm at the very first, or > very last item in the array. How do I do this. Below is the pseudo code > which would be ideal: > > while (list ($key, $val) = each ($info)) > { > if(onFirstKey or onLastKey) > do fun stuff > else > do other stuff > } > > Please help. Thanks

« previous php.general (#112867) next »