php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #25237 Two, associative array functions
Submitted: 2003-08-25 11:56 UTC Modified: 2003-08-25 19:28 UTC
From: gavin at itmerge dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.3 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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
13 + 1 = ?
Subscribe to this entry?

 
 [2003-08-25 11:56 UTC] gavin at itmerge dot com
Description:
------------
I wasn't able to use array_slice or array_splice on my associative arrays so I wrote two functions that others may find useful.

Reproduce code:
---------------
/* Remove a list of Associative keys 
from an array
*/
function array_unset(&$array,$list) {
  foreach($list as $val) {
    unset($array[$val]);
  }
}  

/* Transport a list of Associate keys 
from one array to another
*/
function array_trans(&$arrayfrom,&$arrayto,$list) {
  foreach ($list as $val) {
    $arrayto[$val]=$arrayfrom[$val];
    unset($arrayfrom[$val]);
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-25 19:28 UTC] sniper@php.net
As you proved yourself, it can be done easily with PHP code.
Post those funcs as manual notes instead, maybe someone finds them useful too.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 13:01:46 2024 UTC