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
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gavin at itmerge dot com
New email:
PHP Version: OS:

 

 [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: Mon Jun 17 16:01:29 2024 UTC