php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66000 Unpacking nested arrays with list
Submitted: 2013-10-30 11:57 UTC Modified: 2013-10-31 18:14 UTC
From: info at pkrules dot in Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.4.21 OS: windows 8 pro
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: info at pkrules dot in
New email:
PHP Version: OS:

 

 [2013-10-30 11:57 UTC] info at pkrules dot in
Description:
------------
---
From manual page: http://www.php.net/control-structures.foreach
---


The 

Unpacking nested arrays with list() is not working showing Parse error: syntax error, unexpected 'list' (T_LIST) in line...PHP Version 5.4.7

Test script:
---------------
<?php
$array = [
    [1, 2],
    [3, 4],
];

foreach ($array as list($a, $b, $c)) {
    echo "A: $a; B: $b; C: $c\n";
}
?>


Expected result:
----------------
elements as output

Actual result:
--------------
error

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-30 12:17 UTC] gabri dot ns at gmail dot com
"PHP 5.5 added the ability..."
the documentation already stated that.
so it is the right response since you using 5.4.7

this is not a bug.
 [2013-10-31 18:14 UTC] bwoebi@php.net
-Status: Open +Status: Not a bug
 [2013-10-31 18:14 UTC] bwoebi@php.net
As noticed by the author; not a bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC