From: jeoe12 at gmail dot com
Operating system: Ubuntu
PHP version: 5.3Git-2013-04-17 (snap)
Package: PHP options/info functions
Bug Type: Bug
Bug description:array_diff_uassoc bug.
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 bug report at https://bugs.php.net/bug.php?id=64655&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64655&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64655&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64655&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64655&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64655&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64655&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64655&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64655&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64655&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64655&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64655&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64655&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64655&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64655&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64655&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64655&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64655&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64655&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64655&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64655&r=mysqlcfg