note 38344 added to function.array-diff-assoc
| From: | jochem at iamjochem dot com | Date: | Wed, 17 Dec 2003 14:14:12 +0000 |
| Subject: | note 38344 added to function.array-diff-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62121@lists.php.net to get a copy of this message | ||
here is a slightly enhanced version of Micheal Johnsons function (posted 26.oct.2003), this version
accepts arguments in the same way as array_diff_assoc (i.e. you can pass as many arrays as you want
- any arguments that are not arrays are ignored). If the first argument is not an array you
automatically get empty array back:
<?
function array_diff_keys()
{
$args = func_get_args();
$res = $args[0];
if(!is_array($res)) {
return array();
}
for($i=1;$i<count($args);$i++) {
if(!is_array($args[$i])) {
continue;
}
foreach ($args[$i] as $key => $data) {
unset($res[$key]);
}
}
return $res;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.array-diff-assoc.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38344
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38344&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38344&report=yes
Search -- http://master.php.net/manage/user-notes.php