[PATCH] array_diff_assoc()
| From: | Andrey | Date: | Tue, 03 Sep 2002 21:51:52 +0000 |
| Subject: | [PATCH] array_diff_assoc() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-87896@lists.php.net to get a copy of this message | ||
Hi,
the attached unified diffs can be used to add new function named
array_diff_assoc(). This function works like array_diff() (and shares most of
it code) but it is more restrictive. An element from the result array is
removed if there is an element in arrays from 2 to N that has same value and
same key.
PHP script for testing is also attached.
Regards,
Andrey
P.S.
Note that basic_functions.c in the CVS is newer than mine.
Attachment: [text/x-diff] array.c.array_diff_assoc.diff
Attachment: [text/x-diff] php_array.ada.h.diff
Attachment: [text/x-diff] basic_functions.ada.c.diff
<?php $a = array(1,"big"=>2,3,6,3,5,3,3,3,3,3,3,3,3,3,3); $b = array(2,2,3,3,3,3,3,3,3,3,3,3,3,3,3); $c = array(-1,1); echo '$a='.var_export($a,TRUE).";\n"; echo '$b='.var_export($b,TRUE).";\n"; echo '$c='.var_export($c,TRUE).";\n"; var_dump(array_diff($a,$b,$c)); var_dump(array_diff_assoc($a,$b,$c)); ?>
Attachment: [text/x-diff] array.c.array_diff_assoc.diff
Attachment: [text/x-diff] php_array.ada.h.diff
Attachment: [text/x-diff] basic_functions.ada.c.diff
<?php $a = array(1,"big"=>2,3,6,3,5,3,3,3,3,3,3,3,3,3,3); $b = array(2,2,3,3,3,3,3,3,3,3,3,3,3,3,3); $c = array(-1,1); echo '$a='.var_export($a,TRUE).";\n"; echo '$b='.var_export($b,TRUE).";\n"; echo '$c='.var_export($c,TRUE).";\n"; var_dump(array_diff($a,$b,$c)); var_dump(array_diff_assoc($a,$b,$c)); ?>