I have the following simple function to try and understand the array_udiff()
function
function udiffCompare( $value, $value2 )
{
echo $value . " - " . $value2 . "<br />";
}
$newArray = array(
'value2' => 2,
'value3' => 3,
'value4' => 4
);
$newArray2 = array(
'value2' => 2,
'value3' => 3,
'value4' => 4
);
array_udiff( $newArray, $newArray2, 'udiffCompare' );
I would expect this to simply return:
2 - 2
3 - 3
4 - 4
However it returns:
3 - 2
4 - 3
3 - 2
4 - 3
4 - 4
4 - 3
4 - 3
3 - 2
This leads me to believe there is something I am really not understanding here about how array_udiff()
works.
Even if I replace the echo statement above with:
if( $value == $value2 ) { return 1; } else { return 0; }
the outputted array is completely empty even though all the values passed to the function are equal.
Could someone shine a light please?