Bug #14513 Updated: Fetch multiple elements from an array
| From: | zak@php.net | Date: | Mon, 17 Dec 2001 07:26:26 +0000 |
| Subject: | Bug #14513 Updated: Fetch multiple elements from an array | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-74087@lists.php.net to get a copy of this message | ||
ID: 14513
Updated by: zak
Reported By: daniel@lorch.cc
Old Status: Open
Status: Closed
Bug Type: Feature/Change Request
Operating System:
PHP Version: 4.1.0
New Comment:
Hey Daniel,
Check out the archived discussions in the zend engine 2
mailing list regarding this topic. :)
Previous Comments:
------------------------------------------------------------------------
[2001-12-14 06:39:22] daniel@lorch.cc
I was thinking about a new feature. Fetching multiple elements would be a cool feature,
wouldn't it? This would look like this;
$array[0,1];
or
$array['name','address'];
and would allow constructions like this:
for($i=0;$i<count($array);$i+=2) {
list($odd,$even)=$array[$i,$i+1];
}
instead of:
for($i=0;$i<count($array);$i+=2) {
$odd=$array[$i];
$even=$array[$i+1];
}
This syntactically follows the specification of using the "comma" to provide multiple
elements/indices, such as it's already the case for functions. Therefore adding this feature
wouldn't deteriorate the code-readability.
Also, I cannot think of any way using this feature to encourage bad coding practices.
$array from the above example could be a datafile from a guestbook where always a pair of lines
represent "username" and "comment" (instead of using "|" or anything
else as a delimitor).
Your comments?
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14513&edit=1