I have two array, let’s say
$array1 = array(0 => 10, 1 => 21, 2 => 34, 'somekey' => 45, 'otherkey' => 15);
$array2 = array(0 => 9, 1 => 10, 2 => 14, 'otherkey' => 15, 'somekey' => 43);
I need to return an array with only the values contained by both arrays, independent of their keys. In this case, the resulting array would contain value 10 at key 0, value 15 at key 1
Use
array_intersect():If you want to get rid of the keys, run that array through
array_values():This will set
$array3to: