Bug #64655 [Fbk->NoF]: array_diff_uassoc bug.

From: Date: Tue, 15 Oct 2013 11:54:42 +0000
Subject: Bug #64655 [Fbk->NoF]: array_diff_uassoc bug.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182237@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64655&edit=1 ID: 64655 Updated by: php-bugs@lists.php.net Reported by: jeoe12 at gmail dot com Summary: array_diff_uassoc bug. -Status: Feedback +Status: No Feedback Type: Bug Package: PHP options/info functions Operating System: Ubuntu PHP Version: 5.3Git-2013-04-17 (snap) Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2013-04-17 14:01:42] laruence@php.net actually, I can not understand what the bug you are talking about..... could you please give us a simple test script, and also the expect result ------------------------------------------------------------------------ [2013-04-17 09:57:21] jeoe12 at gmail dot com Description: ------------ array_diff_uassoc bug.. this function is diff args[0] to args[n-1] * args[n] == "user function" if (args[0].value == args[n-1].value) ==> run to "user function" but.. PHP Version 5.3.5-1ubuntu7.7 not run... Test script: --------------- function key_compare_func($key1, $key2) { echo $key1. " ". $key2 . "<br>"; if ($key1 == $key2) return 0; else if ($key1 > $key2) return 1; else return -1; } $array1 = array('1-1' => 1, '1-2' => 2, '1-3' => 3, '1-4' => 4); $array2 = array('2-1' => 5, '2-2' => 6, '2-3' => 7, '2-4' => 8); var_dump(array_diff_uassoc2($array1, $array2, 'key_compare_func')); Expected result: ---------------- function php_compat_array_diff_uassoc() { $args = func_get_args(); if (count($args) < 3) { user_error('Wrong parameter count for array_diff_uassoc()', E_USER_WARNING); return; } $compare_func = array_pop($args); if (!is_callable($compare_func)) { if (is_array($compare_func)) { $compare_func = $compare_func[0] . '::' . $compare_func[1]; } user_error('array_diff_uassoc() Not a valid callback ' . $compare_func, E_USER_WARNING); return; } $array_count = count($args); for ($i = 0; $i !== $array_count; $i++) { if (!is_array($args[$i])) { user_error('array_diff_uassoc() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); return; } } $result = array(); foreach ($args[0] as $k => $v) { for ($i = 1; $i < $array_count; $i++) { foreach ($args[$i] as $kk => $vv) { if ($v == $vv) { $compare = call_user_func_array($compare_func, array($k, $kk)); if ($compare == 0) { continue 3; } } } } $result[$k] = $v; } return $result; } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64655&edit=1

« previous php.bugs (#182237) next »