How can compare values of two arrays in php -


this question has answer here:

i want compare 1 array values in another. following 2 different arrays.

$a = array (9,39,40,41);  $b = array ( [0] => 38 [1] => 1 [2] => 36 [3] => 37 [4] => 9 [5] => 2 ); 

i want check if $a values in $b. condition should true when $a values exist in $b.

if($a in $b ){ echo 'true'; } 

you can use array_intersect so

$intersection = array_intersect($a, $b); $ok = (count(($intersection) === count($a)); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -