php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35560 Failure on list($a, $b) = $b
Submitted: 2005-12-05 21:27 UTC Modified: 2005-12-12 08:38 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ktk at bigfoot dot com Assigned: dmitry (profile)
Status: Not a bug Package: Arrays related
PHP Version: 5.1.1 OS: GNU/Linux
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:
19 - 16 = ?
Subscribe to this entry?

 
 [2005-12-05 21:27 UTC] ktk at bigfoot dot com
Description:
------------
In PHP 5.1 the list() operator fails to correctly assign values to variables that appear left of the variable that is used as the source array, if the source variable is itself listed as one of the variables to be assigned.

list($a, $b) = $b; fails to properly assign $a.

PHP 5.0 and earlier have no problem with this syntax.


Reproduce code:
---------------
$c = array("Apple", "Banana", "Pear", "Grape", "Orange");
list($a, $b, $c, $d, $e) = $c;
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);
var_dump($e);




Expected result:
----------------
string(5) "Apple"
string(6) "Banana"
string(4) "Pear"
string(5) "Grape"
string(6) "Orange"

Actual result:
--------------
string(1) "P"
string(1) "e"
string(4) "Pear"
string(5) "Grape"
string(6) "Orange"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-05 21:39 UTC] tony2001@php.net
Dmitry, is there something we can do about it?
It definitely looks wrong to me, but somehow it works in 5.0.
 [2005-12-12 08:38 UTC] dmitry@php.net
Duplicated. See http://bugs.php.net/bug.php?id=35277&edit=1
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC