You are here: Re: finding differences between two arary's « All PHP « IT news, forums, messages
Re: finding differences between two arary's

Posted by Kim Andrι Akerψ on 11/04/05 16:57

nescio wrote:

> hello,
>
> i have two array's, lets say:
> $inhoudDir = array('a','b','c','d','e','f','g','x','y','z');
> $inhoudDb = array('a','b','c','x','z');
>
> now i want to compare the two and put the elements that are only in
> $inhoudDir in a new array: $geenDuplicaten;
>
> i have tried things like:
> for($cc = 0; $cc < sizeof($inhoudDir); $cc++){
> for($dd = 0; $dd < sizeof($inhoudDb); $dd++){
> if($inhoudDir[$cc] != $inhoudDb[$dd]){
> $geenDuplicaten[] = $inhoudDir[$cc];
> }
> }
> }
>
>
> but it doesnot work: the array $geenDuplicaten should contain:
> d,e,f,g,y but i do not know how to do this;
>
> thanks

Did you think to look through the manual first? You might've discovered
the function array_diff().

http://php.net/array_diff

--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

 

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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация