Req #35957 [Com]: Array literal syntax support
| From: | rasmus at mindplay dot dk | Date: | Sun, 27 Nov 2011 01:08:30 +0000 |
| Subject: | Req #35957 [Com]: Array literal syntax support | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165518@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=35957&edit=1
ID: 35957
Comment by: rasmus at mindplay dot dk
Reported by: matt at matttoddphoto dot com
Summary: Array literal syntax support
Status: Wont fix
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: Any
PHP Version: 6CVS-2006-01-10 (snap)
Block user comment: N
Private report: N
New Comment:
This feature was implemented in PHP 5.4:
http://svn.php.net/viewvc?view=revision&revision=313641
Previous Comments:
------------------------------------------------------------------------
[2006-01-10 08:36:34] derick@php.net
This was discussed, and rejected, many times before.
------------------------------------------------------------------------
[2006-01-10 08:28:52] matt at matttoddphoto dot com
Description:
------------
It would be lovely to be able to literally define arrays with
simple syntax like the following:
["one", "two", "three"]
instead of the less intuitive:
array("one", "two", "three");
This would simplify creating arrays of arrays (of arrays)
inline for functions. Also, this would help solve the 'named
parameters' request by allowing for an associative array to be
given simply by throwing []s in.
Reproduce code:
---------------
Here is an example just for the sake of clarity:
$validate = [$_POST['post'],
['title'=>'/[A-Za-z0-9_\?\!\.\#\&\%]+/',
"text"=>'/\w*/', 'user_id'=>'/\d+/']];
This would be in opposition to:
$validate = array($_POST['post'],
array('title'=>'/[A-Za-z0-9_\?\!\.\#\&\%]+/',
"text"=>'/.*/', 'user_id'=>'/\d+/'));
You can see how more complex examples can get just that much more complex (the the nth degree).
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=35957&edit=1