php.net |  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
Votes:4
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
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: andreas at dqxtech dot net
New email:
PHP Version: OS:

 

 [2015-07-18 01:44 UTC] andreas at dqxtech dot net
Description:
------------
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:
---------------
<?php

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

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


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-07-18 10:00 UTC] cmb@php.net
-Package: PHP Language Specification +Package: Arrays related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 08 04:01:28 2024 UTC