How to count the values from an array that exist in another array in PHP

1 Answer

0 votes
$haystack = [4, 8, 1, 9];
$target = [5, 7, 2, 8, 1, 6, 4, 0, 12];

echo count(array_intersect($haystack, $target));
 
 
 
 
/*
run:
 
3
 
*/

 



answered Dec 11, 2021 by avibootz
...