[PHP] Getting an advanced foreach to work

2006-05-23 Thread Jonas Rosling
I got the code as follows bellow. I'm having some problems to get it to work. Maybe some of you are able to help me a bit. First of all I got an array (salespersons) containing names of dynamic array names. For example it can contain Johan, Mark, Jenny, Bill etc. By calling for the possision in

SV: [PHP] Getting an advanced foreach to work SOLVED

2006-05-23 Thread Jonas Rosling
-Ursprungligt meddelande- Från: Jonas Rosling [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 10:06 Till: PHP List Ämne: [PHP] Getting an advanced foreach to work Should look like this: foreach (${$salespersons[$count]} AS $key = $value) { -- PHP General Mailing List (http

Re: [PHP] Getting an advanced foreach to work

2006-05-23 Thread cajbecu
this shoul work: while ($count count($salespersons)) { foreach ($salespersons[$count] AS $key = $value) { echo htmlentities($key).' - '.$value; $count++; } } On 5/23/06, Jonas Rosling [EMAIL PROTECTED] wrote: I got the code as follows

Re: [PHP] Getting an advanced foreach to work

2006-05-23 Thread Chris
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

SV: [PHP] Getting an advanced foreach to work

2006-05-23 Thread Jonas Rosling
-Ursprungligt meddelande- Från: Chris [mailto:[EMAIL PROTECTED] Skickat: den 23 maj 2006 10:24 Till: Jonas Rosling Kopia: PHP List Ämne: Re: [PHP] Getting an advanced foreach to work From a performance point of view you're much better off doing: $sales_count = count($salespersons

Re: [PHP] Getting an advanced foreach to work

2006-05-23 Thread Greg Beaver
Chris wrote: 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. Quick