php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #15562 New additions to the array family "array_insert"
Submitted: 2002-02-14 22:50 UTC Modified: 2002-02-15 00:34 UTC
From: jrhardy2002 at yahoo dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.1.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
19 - 11 = ?
Subscribe to this entry?

 
 [2002-02-14 22:50 UTC] jrhardy2002 at yahoo dot com
I believe it would be a very handy feature to have an "array_insert" function (with re-key'ing).  I am in need of such an item and thus my request.  

What I mean by this is if I already have an array with numerical keys, and elements filled in, I would like to be able to insert an element into this pre-existing array.  So if I had 10 elements in my array, all with a key index.  I have a new element that I want to insert into this array, without popping off the end or from the top...I want it in a specific spot in the array.  So I have "newelement" which I want in key5, so I would "array_insert(key(5),newelement)" which would insert it at the appropriate spot without deleting anything there, and "newelement" would now have the key "key5" and the old key5 would now just be key6 and so on, so that I know have 11 elements with numerical keys.

Thanks
John

If that is not clear, please write me and I'll make it more clear.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-15 00:34 UTC] sniper@php.net
per request..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 17:01:29 2024 UTC