php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34360 array_push with the new key as return value
Submitted: 2005-09-03 14:59 UTC Modified: 2015-01-08 23:46 UTC
Votes:3
Avg. Score:4.3 ± 0.5
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: yaxay at gmx dot net Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.0.4 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yaxay at gmx dot net
New email:
PHP Version: OS:

 

 [2005-09-03 14:59 UTC] yaxay at gmx dot net
Description:
------------
The function array_push returns the count of the array after the new element/s is/are pushed onto it. However it would be rather useful to have the key of the first pushed value returned. Until now I have to rely on a rather slow user function to do the same.
Of course it makes no sense to modify the function, because some may need it to return the element count. However I think it would be very handy to be able to access the elements after pushing them onto the stack, therefore I wonder whether you could create a built in function to do so.

PS: I was not allowed to pick irrelevant for PHP version, so I picked 5.0.4 since I'm currently developing for PHP5 only. The funtion would be great for PHP4 too, though.
PPS: I hope I did not overlook an already existing function..

Sincerely,
Benjamin Schulz


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-08 23:46 UTC] ajf@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2015-01-08 23:46 UTC] ajf@php.net
Unlikely to be changed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC