It depend on how many values to check using in_array. If more than two, better way is loops through array and runs an in_array of it on the checking array. Returns true once something is found, else it returns false.
$main_array = array(1,2,3,4,5); $check_value = array(1,3,6,8); foreach ($check_value as $value) { if (in_array($value, $main_array)) { return true; } else{ return false; } }
If only two, probably can use if:
if(in_array('foo',$arg) && in_array('bar',$arg)){ //both of them are in $arg } if(in_array('foo',$arg) || in_array('bar',$arg)){ //at least one of them are in $arg }
Reference: http://stackoverflow.com/questions/7542694/in-array-multiple-values
What do you think?