cvs: pear /PHP_Compat/Compat/Function array_diff_assoc.php

From: Date: Tue, 08 Jun 2004 15:13:17 +0000
Subject: cvs: pear /PHP_Compat/Compat/Function array_diff_assoc.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-20359@lists.php.net to get a copy of this message
aidan Tue Jun 8 11:13:17 2004 EDT Modified files: /pear/PHP_Compat/Compat/Function array_diff_assoc.php Log: Initial attempt - does not work http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_diff_assoc.php?r1=1.1&r2=1.2&ty=u Index: pear/PHP_Compat/Compat/Function/array_diff_assoc.php diff -u pear/PHP_Compat/Compat/Function/array_diff_assoc.php:1.1 pear/PHP_Compat/Compat/Function/array_diff_assoc.php:1.2 --- pear/PHP_Compat/Compat/Function/array_diff_assoc.php:1.1 Thu Jun 3 04:51:14 2004 +++ pear/PHP_Compat/Compat/Function/array_diff_assoc.php Tue Jun 8 11:13:17 2004 @@ -16,7 +16,7 @@ // | Authors: Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: array_diff_assoc.php,v 1.1 2004/06/03 08:51:14 aidan Exp $ +// $Id: array_diff_assoc.php,v 1.2 2004/06/08 15:13:17 aidan Exp $ // @@ -31,26 +31,48 @@ * @added PHP 4.3.0 * @requires PHP 3 */ -if (!function_exists('array_diff_assoc')) +if (!function_exists('array_diff_assoc2')) { - function array_diff_assoc () + function array_diff_assoc2 () { $args = func_get_args(); - - $res = $args[0]; - if(!is_array($res)) { - return array(); + if (count($args) < 2) { + trigger_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING); + return null; } - - for($i=1;$i<count($args);$i++) { - if(!is_array($args[$i])) { - continue; + + // Check arrays + $count = count($args); + for ($i = 0; $i < $count; $i++) + { + if (!is_array($args[$i])) { + trigger_error('array_diff_assoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return null; } - foreach ($args[$i] as $key => $data) { - unset($res[$key]); + } + + $diff = array (); + // Traverse values of the first array + foreach ($args[0] as $key => $value) + { + // Loop through each other array + for ($i = 1; $i < $count; $i++) + { + // Loop through the current arrays key/val pairs and compare + foreach ($args[$i] as $comp_key => $comp_value) + { + if ((string)$key === (string)$comp_key && + (string)$value === (string)$comp_value) { + + echo 'found a match'; + } + } } + + $diff[$key] = $value; } - return $res; + + return $diff; } } ?>

« previous php.pear.cvs (#20359) next »