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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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 Apr 18 01:01:28 2024 UTC