RE: [PHP] learning php - problem already
| From: | Van Andel, Robbert | Date: | Tue, 29 Jul 2003 20:52:37 +0000 |
| Subject: | RE: [PHP] learning php - problem already | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-157431@lists.php.net to get a copy of this message | ||
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: karin@justinfo.info [mailto:karin@justinfo.info]
Sent: Tuesday, July 29, 2003 1:43 PM
To: php-general@lists.php.net
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