[PHP-BUG] Req #70094 [NEW]: Allow default values for list()
[email protected] ("andreas at dqxtech dot net")
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
From: andreas at dqxtech dot net
Operating system: Linux
PHP version: 5.6.11
Package: PHP Language Specification
Bug Type: Feature/Change Request
Bug description:Allow default values for list()
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".
--
Edit bug report at https://bugs.php.net/bug.php?id=70094&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70094&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70094&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70094&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70094&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70094&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70094&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70094&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70094&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70094&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70094&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70094&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70094&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70094&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70094&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70094&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70094&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70094&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70094&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70094&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70094&r=mysqlcfg