PHP if array found in another array

49 views Asked by At

I want to write a condition to take an action based on an array value found on another array. It currently is not working.

$Main = array('Ami', 'Tumi', 'Amra');
$Search = array('Jani', 'Ami', 'Kara');
if(in_array($Search, $Main)){
    echo "Found";
}
1

There are 1 answers

0
Feroz Ahmed On BEST ANSWER

You can try this.

$CheckNow = !empty(array_intersect($Main, $Search));
if ($CheckNow) {
    # code...
}