Req #48542 [Opn->Fbk]: array_shift/_pop should fetch the key
| From: | levim@php.net | Date: | Wed, 16 Apr 2014 21:59:29 +0000 |
| Subject: | Req #48542 [Opn->Fbk]: array_shift/_pop should fetch the key | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185307@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=48542&edit=1
ID: 48542
Updated by: levim@php.net
Reported by: simon at stienen dot name
Summary: array_shift/_pop should fetch the key
-Status: Open
+Status: Feedback
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: Arrays related
PHP Version: 5.3.0RC3
Block user comment: N
Private report: N
New Comment:
Is this something you are still interested in? I think array_pop and array_shift are designed to
work with stack and queue like behavior, so the key is completely irrelevant.
Previous Comments:
------------------------------------------------------------------------
[2009-06-13 10:46:38] simon at stienen dot name
Description:
------------
The functions array_shift and array_pop should get an optional second parameter, taking a reference
to a variable in which the key of the shifted/popped element will be stored.
Reproduce code:
---------------
<?php
$a = array(
'foo' => 'bar',
'qux' => 'quux'
);
$value = array_shift($a, $key);
echo "$key: $value";
Expected result:
----------------
foo: bar
Actual result:
--------------
array_shift does not take a second parameter at the moment.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=48542&edit=1