|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70094 Allow default values for list()
Submitted: 2015-07-18 01:44 UTC Modified: 2015-07-18 10:00 UTC
Avg. Score:2.8 ± 1.8
Reproduced:2 of 4 (50.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: andreas at dqxtech dot net Assigned:
Status: Open Package: Arrays related
PHP Version: 5.6.11 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-07-18 01:44 UTC] andreas at dqxtech dot net
Sometimes I want to use the list() construct to unpack an array, but I don't know the size of the array. In this case, list() will give me a "Notice: Undefined index ..".

It would be nice if I could specify default values, as in the code below.

Test script:

list($a, $b = 'bbb', $c = 'ccc') = array('AAA', 'BBB');
print "$a, $b, $c";

// Output: "AAA, BBB, ccc".


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-18 10:00 UTC]
-Package: PHP Language Specification +Package: Arrays related
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 19:01:29 2024 UTC