0

I have two Arrays (but in reality they have much more content):

Array $erg

Array ( [0] => 4004708326000 [1] => 4004708392555 [2] => 4004708385106)

and Array $eannummer:

Array ( [0] => 4004708326000 [1] => 4004708392555 [2] => 4004708285234)

I tried to compare them with array_diff to get all the Numbers that are in $erg but not in $eannummer

print_r (array_diff($erg, $eannummer));

this only prints out

Array ()

but I can't manage to find out why...

Thanks in advance

1
  • Cannot reproduce the problem. 3v4l.org/FLqdC Please show your code Commented Dec 13, 2013 at 8:44

2 Answers 2

1

babl@wks35:~$ cat 17.php It works for me:

<?php
$erg = Array ( 0 => 4004708326000, 1 => 4004708392555, 2 => 4004708385106);
$eannummer = Array ( 0 => 4004708326000, 1 => 4004708392555, 2 => 4004708285234);

print_r($erg);
print_r($eannummer);
print_r(array_diff($eannummer,$erg));
print_r(array_diff($erg,$eannummer));
?>
babl@wks35:~$ php 17.php 
Array
(
    [0] => 4004708326000
    [1] => 4004708392555
    [2] => 4004708385106
)
Array
(
    [0] => 4004708326000
    [1] => 4004708392555
    [2] => 4004708285234
)
Array
(
    [2] => 4004708285234
)
Array
(
    [2] => 4004708385106
)
2
  • Of course this does work, but I have almost 500 entries in array $erg and 300 in array $eannummer, when I try to compare the whole arrays, it does not seem to work for me.... Commented Dec 13, 2013 at 8:51
  • And how we can check this? Put your "not working" code to pastebin or dropbox. Commented Dec 13, 2013 at 8:53
0

This is help you

$resultDiff = array_diff($array2, $array1);

array_diff()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.