How can you efficiently match values from different arrays in PHP?

When matching values from different arrays in PHP, one efficient way is to use the array_intersect function. This function takes multiple arrays as arguments and returns an array containing values that are present in all input arrays. By using array_intersect, you can easily find common values between arrays without having to iterate through each array manually.

$array1 = [1, 2, 3, 4, 5];
$array2 = [3, 4, 5, 6, 7];
$array3 = [5, 6, 7, 8, 9];

$commonValues = array_intersect($array1, $array2, $array3);

print_r($commonValues);