|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48542 array_shift/_pop should fetch the key
Submitted: 2009-06-13 10:46 UTC Modified: 2014-12-30 10:41 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: simon at stienen dot name Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 5.3.0RC3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: simon at stienen dot name
New email:
PHP Version: OS:


 [2009-06-13 10:46 UTC] simon at stienen dot name
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:

$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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-16 21:59 UTC]
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: Arrays related
 [2014-04-16 21:59 UTC]
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.
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 17:01:33 2024 UTC