|
Posted by Steve on 09/26/04 11:31
> $inhoudDir = array('a','b','c','d','e');
> $inhoudDb = array('b','e');
> $geenDuplicaten = array_diff($inhoudDir, $inhoudDb);
>
> for($x=0; $x < sizeof($geenDuplicaten); $x++){
> echo 'geenduplicaten: ' . $geenDuplicaten[$x] . "<br>";
> }
I suggest you do 3 things. In your test script, after:
$geenDuplicaten = array_diff($inhoudDir, $inhoudDb);
add the line:
print_r( $geenDuplicaten );
to see what the new array contains. Notice in particular the keys of
the elements.
Now go and read the manual page <http://www.php.net/array_diff>. What
does this page tell you about the way keys are handled? Now look at
your loop, and think about what happens when it executes - what happens
when $x == 1?
Finally, check what your script's error handling level is set to, to
find out why the warning that should be displayed is not displayed.
---
Steve
[Back to original message]
|