Is there anyway to compare arrays in php using an inbuilt function, short of doing some sort of loop?
$a1 = array(1,2,3); $a2 = array(1,2,3); if (array_are_
this is a simple way to get the difference:
$array1 = [40,10,30,20,50]; $array2 = [10,30]; $result = array_filter( $array1, function($var) use($array2){ if(in_array($var, $array2)){ return $var; } } ); print_r($result); //Array ( [0] => 10 [1] => 30 )