|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-12-13 07:49 UTC] wishm at bk dot ru
Description:
------------
array_diff() function fails on comparing any array element with 2, when another pair of elements are both set to 2. Fails with that settings only.
Reproduce code:
---------------
<?php
$a = array("2","2");
$b = array("2","any_symbols_here");
// same thing on $b = array("any_symbols_here","2");
print_r(array_diff($a,$b));
?>
Expected result:
----------------
Array ( [1] => 2 )
// second elements are not equal so function should return that element from $a array
Actual result:
--------------
Array ( )
//empty array - function failed
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 04:00:02 2025 UTC |
I think you dont understand the purpose of the array_diff() function. The element is considered present if and only if its' VALUE is equal to the same-named element's VALUE in the second array! Try array_diff(array("a"=>"1"),array("a"=>"2")). The element a = 1 does not present at second array so it will be returned. You didnt even tried to understand the essence of the bug! It is 100% PHP error when 2 is considered equal to ANY value under conditions I've described. Please fix that!