I can't help you with the while loop, but foreach loops are very nice to
work with.  It took me a while to figure it out as well.


You can use the foreach to loop through all the instances of an array.  This
works best when you have an associative array ($state['CA'] = "Sacremento",
$state['OR'] = "Salem", etc.)

foreach ($state as $abbreviation => $capital)

The above foreach statement takes the index of state and assigns it to
$abbreviation, while it takes the actual value and assigns it to $capital.
The process is repeated for each instance of $state.

Hope this helps.

Robbert van Andel 


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 1:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP] learning php - problem already



Hello everyone,
Am new to php and have run into a problem while reading my book... can
anybody tell me what does this mean:

foreach($invoice as $number => $pppno)

and also this:

while(list($k,$v,) = each($a))

I do understand for loops and while loops but this is a bit confusing...do
you haev any links I can read up on these?

Thanks in advance,
-Karin Cooke.

-- 
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

Reply via email to