php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #12257 list() can't handle associative arrays
Submitted: 2001-07-19 11:40 UTC Modified: 2016-03-27 21:04 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: daniel_sevcik at hotmail dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: * OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniel_sevcik at hotmail dot com
New email:
PHP Version: OS:

 

 [2001-07-19 11:40 UTC] daniel_sevcik at hotmail dot com
<?php
	$tmp=array(0=>1, "test"=>2);
	list($xx,$yy)=$tmp;
	echo("$xx, $yy");
?>

---Output:start---
1,
---Output:end-----

Variable $yy is empty (only if key name is not integer).
$tmp=array(0=>1, 1=>2);
In this case - it works...

Danny

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-31 10:23 UTC] sander@php.net
List() can't handle associative arrays. Moved to feature request.
 [2002-03-27 21:24 UTC] philip@php.net
This is now documented as a <note>.

A good feature request is to have list work on associative arrays, which would also mean it won't rely on perfect 0,1,2... order either.

Imho this is a .5 bug and .5 feature request.  Could someone explain why the current behavoir exists?  See also the user notes under list().
 [2010-12-14 12:05 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: W2000, Debian +Operating System: * -PHP Version: 4.0.6 +PHP Version: *
 [2016-03-27 21:04 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2016-03-27 21:04 UTC] nikic@php.net
Support for associative array destructuring using list() has been added in PHP 7.1, see also: https://wiki.php.net/rfc/list_keys
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Mar 11 06:01:29 2025 UTC