I'm trying to use array_diff like so. Here are my two array outputs:
List 1 Output
Array ([0] => 0022806 )
List 2 Output
Array ([0] => 0022806 [1] => 0023199 )
PHP
$diff = array_diff($list_1, $list_2);
print "DIFF: " . count($diff) ."<br>";
print_r($diff);
The Output is:
DIFF: 0
Array ( )
Any idea what I'm doing wrong? Why is 0023199
not returned?
The order of arguments in array_diff() is important
Returns an array containing all the entries from array1 that are not present in any of the other arrays
try;
$diff = array_merge(array_diff($list_1, $list_2), array_diff($list_2, $list_1));
print "DIFF: " . count($diff) ."<br>";
print_r($diff);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With