Re: Getting an advanced foreach to work

From: Date: Tue, 23 May 2006 08:23:47 +0000
Subject: Re: Getting an advanced foreach to work
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236698@lists.php.net to get a copy of this message
Jonas Rosling wrote: ...
while ($count < count($salespersons)) {
I see you have solved it - just one comment. This particular line will get evaluated every time. If you have a large number of elements in $salespersons, it will slow things down considerably. From a performance point of view you're much better off doing: $sales_count = count($salespersons); while($count < $sales_count) { .... The only reason to leave the count in the while statement is if you are adding/removing to that array within the loop, otherwise chuck it in a temp variable and use that instead. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#236698) next »