PHP Comparing 2 Arrays For Existence of Value in Each

Posted by Dr. DOT on Stack Overflow See other posts from Stack Overflow or by Dr. DOT
Published on 2011-01-14T14:22:07Z Indexed on 2011/01/15 3:53 UTC
Read the original article Hit count: 281

Filed under:
|
|

I have 2 arrays. I simply want to know if one of the values in array 1 is present in array 2. Nothing more than returning a boolean true or false

Example A:

$a = array('able','baker','charlie');
$b = array('zebra','yeti','xantis');

Expected result = false

Example B:

$a = array('able','baker','charlie');
$b = array('zebra','yeti','able','xantis');

Expected result = true

So, would it be best to use array_diff() or array_search() or some other simple PHP function?

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays