Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
    
Cannot reproduce the problem. 3v4l.org/FLqdC Please show your code –  hek2mgl Dec 13 '13 at 8:44

2 Answers 2

This is help you

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

array_diff()

share|improve this answer

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
)
share|improve this answer
    
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.... –  Chrisis Dec 13 '13 at 8:51
    
And how we can check this? Put your "not working" code to pastebin or dropbox. –  BaBL86 Dec 13 '13 at 8:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.