Bug #63833 [NEW]: udiff doesn't compare properly inside arrays
From: francois dot dambrine at isen-lille dot fr
Operating system: Windows
PHP version: 5.5.0alpha2
Package: Arrays related
Bug Type: Bug
Bug description:udiff doesn't compare properly inside arrays
Description:
------------
This bug was introduced to me by a stackoverflow post
http://stackoverflow.com/questions/13815287/union-two-associative-array-
php/13815578#13815578 I tested the behaviour with php 5.5 Alpha 2 and the
"bug" is
still there.
As of the documentation, it is said that array_diff uses an "internal
function" to
compare two elements.
As equality is the only thing that matters for array_diff I thought this
internal
function was something that "==" behind.
But even if two arrays are equal (same members) array_diff does not take it
in
account.
I mark it as a bug but it can only be a documentation problem.
Test script:
---------------
<?php
$A = Array(
array(
'lable' =>"label0",
'id_poste'=>1,
'id_part'=>11
),
array(
'lable' =>"label1",
'id_poste'=>2,
'id_part'=>12
),
array(
'lable' =>"label2",
'id_poste'=>3,
'id_part'=>13
),
array(
'lable' =>"label3",
'id_poste'=>4,
'id_part'=>14
)
);
$B = Array(
array(
'lable' =>"label0",
'id_poste'=>1,
'id_part'=>11
),
array(
'lable' =>"label1_X",
'id_poste'=>2,
'id_part'=>12
),
array(
'lable' =>"label2",
'id_poste'=>3,
'id_part'=>13
),
array(
'lable' =>"label3_X",
'id_poste'=>4,
'id_part'=>14
)
);
var_dump(array_diff_assoc($B,$A));
Expected result:
----------------
Array(2){
[0]=>array(3){
["lable"] =>"label1_X",
["id_poste"]=>2,
["id_part"]=>12
},
[1]=>array(3){
["lable"] =>"label3_X",
["id_poste"]=>4,
["id_part"]=>14
}
}
Actual result:
--------------
array(0){
}
--
Edit bug report at https://bugs.php.net/bug.php?id=63833&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63833&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63833&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63833&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63833&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63833&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63833&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63833&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63833&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63833&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63833&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63833&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63833&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63833&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63833&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63833&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63833&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63833&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63833&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63833&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63833&r=mysqlcfg
Thread (5 messages)
- francois dot dambrine at isen-lille dot fr