cvs: pear /PHP_Compat/Compat/Function array_uintersect_uassoc.php
| From: | Aidan Lister | Date: | Sat, 11 Sep 2004 10:11:11 +0000 |
| Subject: | cvs: pear /PHP_Compat/Compat/Function array_uintersect_uassoc.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-23828@lists.php.net to get a copy of this message | ||
aidan Sat Sep 11 06:11:11 2004 EDT
Modified files:
/pear/PHP_Compat/Compat/Function array_uintersect_uassoc.php
Log:
Properly compares each key and each value now, thanks to ortega@php.net
http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php?r1=1.9&r2=1.10&ty=u
Index: pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php
diff -u pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.9
pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.10
--- pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.9 Tue Sep 7 03:22:51 2004
+++ pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php Sat Sep 11 06:11:07 2004
@@ -15,7 +15,7 @@
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: array_uintersect_uassoc.php,v 1.9 2004/09/07 07:22:51 aidan Exp $
+// $Id: array_uintersect_uassoc.php,v 1.10 2004/09/11 10:11:07 aidan Exp $
/**
@@ -25,7 +25,7 @@
* @package PHP_Compat
* @link http://php.net/function.array_uintersect_uassoc
* @author Aidan Lister <aidan@php.net>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
@@ -71,15 +71,17 @@
// Traverse values of the first array
$intersect = array ();
foreach ($args[0] as $key => $value) {
- // Check all arrays
+ // Check against each array
for ($i = 1; $i < $count; $i++) {
- if (!array_key_exists($key, $args[$i])) {
- continue;
- }
- $result = call_user_func($key_compare_func, $value, $args[$i][$key]);
- if ($result === 0) {
- $intersect[$key] = $value;
- continue;
+ // Traverse each element in current array
+ foreach ($args[$i] as $ckey => $cvalue) {
+ // Compare key and value
+ if (call_user_func($key_compare_func, $key, $ckey) === 0 &&
+ call_user_func($data_compare_func, $value, $cvalue) === 0) {
+
+ $intersect[$key] = $value;
+ continue;
+ }
}
}
}