Curt Zirzow wrote:
Ok... I'm getting the red pen out now :)
[snip]
the each() function  returns a one element array that the current
(internal) array pointer is pointing to and will return false if at
the end of the array.

It actually returns a four element array (as per the manual).


the list() function (not really a function) takes an array on the
right side of the = operator and assigns each variable its value in
order returned from the array.

Right


so with the example array(0 => 'one', 1 => 'two'), the initial internal
pointer is looking at the first item so when the while statement
evaluates the the statement the each() function returns: 0 => 'one'

The four element array will be 1 => 'one' value => 'one' 0 => 0 key => 0

This array gets returned to the list statement
  list($k, $v)

and apparently list() will ignore the keys that do not have numerical indexes. The manual says numerical indexes are required, but not what happens when they are encounted. It looks like they are just ignored.


list($k,$v) = array('foo'=>'one','two','three');

for example will give $k = 'two', and $v = 'three'. 'one' is completely ignored because it does not have a numerical key.

Kind of a wierd operation that "works" without you knowing all of the details, I guess. I had to come home and actually test some things out before I realized these last bits. :)

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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



Reply via email to