-1

I want to compare one array values in another. Following are two different arrays.

$a = Array (9,39,40,41);

$b = Array ( [0] => 38 [1] => 1 [2] => 36 [3] => 37 [4] => 9 [5] => 2 );

I want to check if $a values are in $b. Condition Should true when $a all values are exist in $b.

if($a in $b ){ echo 'true'; }
Ayaz Ali Shah
  • 634
  • 2
  • 7
  • 16

1 Answers1

0

You can use array_intersect like so

$intersection = array_intersect($a, $b);
$ok = (count(($intersection) === count($a));
Mat
  • 2,134
  • 1
  • 18
  • 21