You are here: Re: strange array_diff() problem « All PHP « IT news, forums, messages
Re: strange array_diff() problem

Posted by Steve on 10/01/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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация