Re: why doesn't list() handle associative arrays?

From: Date: Wed, 07 Feb 2001 02:09:17 +0000
Subject: Re: why doesn't list() handle associative arrays?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-45912@lists.php.net to get a copy of this message
Cynic writes: > $a['x'] = 'one' ; > $a['y'] = 'two' ; > $a['z'] = 'three' ; > > list( $x , $y , $z ) = $a ; > > Warning: Undefined offset: 2 in ... > Warning: Undefined offset: 1 in ... > Warning: Undefined offset: 0 in ... You mean that this: $a['x'] = 'one'; $a['y'] = 'two'; $a['z'] = 'three'; list($x, $y, $z) = $a; ...should work like this? $x = current(each($a)); $y = current(each($a)); $z = current(each($a)); Given that numeric indices doen't necessarily indicate element positions, I don't see why that your request wouldn't be reasonable. -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Adcore Finland| |http://www.coastnet.com/~torben http://www.adcore.com| |Ph: 1.604.709.0506 torben@adcore.com| +----------------------------------------------------------------+

« previous php.dev (#45912) next »