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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
18 + 28 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC