Re: checking values between arrays

From: Date: Fri, 07 Jul 2000 13:39:27 +0000
Subject: Re: checking values between arrays
Groups: php.general 
Request: Send a blank email to php-general+get-5376@lists.php.net to get a copy of this message
Where did you find this function?? And are there more of these hidden functions? Mike Andrei Zmievski <andrei@ispi.net> on 07-07-2000 15:37:21 To: "Thomas Edison Jr." <thomasedisonjr@yahoo.com> cc: php-general@lists.php.net (bcc: Mike Bosschaert/YEU/Yakult WW) Subject: Re: [PHP] [PHP-GENERAL] checking values between arrays On Fri, 07 Jul 2000, Thomas Edison Jr. wrote: > I got two arrays, both has got some words in different > locations, how do i check wether any of the words in > any location of the first array exist in any location > of the second array? > > I tried running both arrays in multiple loops and > putting an if condition, but it checks for only one > word. If there are two common words, it doesn't give > correct answer. Try array_intersect() function. <? $a1 = array('red', 'green', 'blue'); $a2 = array('green', 'yellow', 'ochre'); $result = array_intersect($a1, $a2); ?> $result should be array('green'). -Andrei * Life may be expensive, but it includes an annual free trip around the sun. * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#5376) next »