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

Hi... let's see who gets this one first... :)

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

$invoice is an array. foreach() is going to loop through that array one
element at a time. For each element, it'll take the key and place it into
$number. It will take the value of the element and place it in $pppno. So,
if you had array('one','two'), the first element is "one" with a key of zero
(default). So, the first time through the loop, $number will be zero and
$pppno will be "one". The next time through the loop, $number will be one
and $pppno will be "two".

> and also this:
>
> while(list($k,$v,) = each($a))

Same kind of thing here, just a different method. each() loops through an
array. For each element, it'll return an array consisting of the key and
value. list() takes that array and assigns the first element of the array to
$k and the second to $v. The final while() just loops through everything
until all of the elements of $a have been run through. So, if we have our
array('one','two); again, each() will take the first element, "one", and
pass an array consisting of the key, zero, and the value, "one" to list().
list() will assign zero to $k and "one" to $v.

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

Hope that helps. That was as much of a test for me in seeing if I could
explain it, so tell me how I did! :)

---John Holmes...


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

Reply via email to