[Solved] Return only value that exists in array php


You are looking for array_intersect()

$array1 = ['apple'];;
$array2 = ['apple', 'orange'];
$result = array_intersect($array1, $array2);
print_r($result);

1

solved Return only value that exists in array php