Edit report at http://bugs.php.net/bug.php?id=52321&edit=1
ID: 52321 Comment by: saltybaldyev at gmx dot com Reported by: saltybaldyev at gmx dot com Summary: list() fails under a mere condition Status: Open Type: Bug Package: Variables related Operating System: linux,windows PHP Version: 5.3.2 New Comment: the same if we do list($a,$b,$c)=$c, list($a,$c,$b)=$c and so on. i guess such assignments only work properly in case its right part goes to list() first: list(--> $c <--,$a1,$a2,$a3,...)=$c Previous Comments: ------------------------------------------------------------------------ [2010-07-12 20:52:11] saltybaldyev at gmx dot com Description: ------------ let $b=array(# , #). then list($a,$b) = $b fails. moar precise: after the assigment we'd get $b = $b[1], $a = { $b[1][0], if $b[1] is a string/array NULL, if $b[1] is a number } if $b[1] is an object we'd get a fatal error 'cant convert object->array'. ////////////////// it works correctly if we try list($b,$a)=$b. so an easy fix could be forged in just 2 additional steps: swap arguments * do the usual work * swap results Test script: --------------- $a = 1; $b = array('ohno','yeah'); list($a,$b) = $b; print_r(array('a'=>$a,'b'=>$b)); Expected result: ---------------- Array ( [a] => ohno [b] => yeah ) Actual result: -------------- Array ( [a] => y [b] => yeah ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52321&edit=1