Forum Moderators: coopster

Message Too Old, No Replies

checking in two arrays ?

         

PHPycho

4:36 am on Nov 20, 2008 (gmt 0)

10+ Year Member



Hello forums!
Case:
Suppose we have two arrays(returned by queries)
$array1 and $array2 of different sizes for example (two cases here)
a>
[PHP]$array1 = array(1,2,3);
$array2 = array(1,2);[/PHP]

b>
[PHP]$array1 = array(1);
$array2 = array(1,2,4,5);[/PHP]

I would like to check presence of any values of $array1 in $array2.
How to accomplish this, any ideas.
Thanks in advance for the suggestions.

[edited by: PHPycho at 4:38 am (utc) on Nov. 20, 2008]

cameraman

4:59 am on Nov 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look at array_intersect [php.net]