> -----Original Message----- > From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] > Sent: 31 July 2003 15:54 > you basically > have this: > > list($k,$v,$key,$value) = array(1=>'abc', 'value'=>'abc', 0=>'a', > 'key'=>'a'); > > So, how this works is that list starts with $value. $value is > at position > number four, so since arrays start at zero, it's going to > look in the array > that was passed for an element at [3]. Since there is no [3] > in the passed > array, you get a NOTICE about undefined offset. > > Next it moves on to $key and looks for element [2]. Again you > get a warning > since there is no element [2] in the passed array. > > Next is $v and list is looking for [1]. Since [1] does exist > and has a value > of 'abc', now $v = 'abc' > > Last is $k and [0] and you get $k = 'a'. > > That's how it works. :) > > That's why this code: > > list($a, $b, $c, $d) = array(4=>'four', 3=>'three', 2=>'two', > 1=>'one', > 0=>'zero'); > echo "$a, $b, $c, $d"; > > gives: > > zero, one, two, three
Ho, thanks for that -- I must admit I hardly ever use each() or list(), and taking a quick look at the current manual page for list() does seem to have changed quite a bit since I originally read it -- so I guess my understanding of it was faulty. I still think it's quite confusing -- your explanation here is much better -- so I might see if I can't put together something even better for incorporation in the manual! Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php