Bug #70763 [NEW]: Bug in array_udiff()?

From: Date: Wed, 21 Oct 2015 21:16:04 +0000
Subject: Bug #70763 [NEW]: Bug in array_udiff()?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196733@lists.php.net to get a copy of this message
From:             jonjohnson1 at yandex dot com
Operating system: Windows
PHP version:      5.6.14
Package:          *General Issues
Bug Type:         Bug
Bug description:Bug in array_udiff()?

Description:
------------
function value_compare_func($a, $b){
    if ($a === 'n_3') {
        return 0;
    }
    return 1;
}
$array1 = array("n_1", "n_2", "n_3", "n_4" );
$array2 = array("green");
$result = array_udiff($array1, $array2, "value_compare_func");
print_r($result);

The expected output is:

Array([0] => 'n_1', [1] => 'n_2' , [3] => 'n_4' )

But PHP outputs:

Array([1] => 'n_2' , [3] => 'n_4' )

Where is n_1?


Test script:
---------------
$array1 = array("n_1", "n_2", "n_3", "n_4" );
$array2 = array("green");
$result = array_udiff($array1, $array2, "value_compare_func");
print_r($result);

Expected result:
----------------
Array([0] => 'n_1', [1] => 'n_2' , [3] => 'n_4' )

Actual result:
--------------
Array([1] => 'n_2' , [3] => 'n_4' )

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70763&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70763&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70763&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70763&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70763&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70763&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70763&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70763&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70763&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70763&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70763&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70763&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70763&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70763&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70763&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70763&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70763&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70763&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70763&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70763&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70763&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#196733) next »