Re: Getting an advanced foreach to work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this shoul work:

while ($count < count($salespersons)) {

        foreach ($salespersons[$count] AS $key => $value) {

                echo htmlentities($key).' - '.$value;

                $count++;
        }

}




On 5/23/06, Jonas Rosling <webmaster@xxxxxxxxxxxx> wrote:
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 the array based on $count I'll get the name,
and that's the name of another array. The problem is in the foreach
with ( { } ).

$count = 0;

// Loopa så länge räknaren är mindre än storleken av arrayn $salespersons
while ($count < count($salespersons)) {

        foreach (${$($salespersons[$count])} AS $key => $value) {

                echo htmlentities($key).' - '.$value;

                $count++;
        }

}

Anyone?

Thaks // Jonas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux