You are here: comparing two arrays « PHP Programming Language « IT news, forums, messages
comparing two arrays

Posted by Gerard Matthew on 11/17/05 16:18

What i need to do is compare two arrays and return an array that only
has those that are not in the main table.It's similar to what you could
do with SQL.

Array 1 - List of Everything
Array 2 - List of Some of Array 1

What i want to obtain is Those of Array 1 that are not in Array 2. I
would prefer not to do the following:

function getUnique($array1, $array2) {

foreach ($array1, $key => $value) {
$array2_key = array_search($array2,$value)

if ($array2_key === false)
$result_array[] = $value;


}

return $result_array;
}

Is there any simplier way of doing this...any predefined function in
php that could do this??

Regards,
Gerard Matthew.

 

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

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