Need to match 2 keys in 2 multidimensional arrays and return matches from the first array if found.
array1 =>
$arr[1] = array('fruit' => 'apple', 'ver' => '1', 'color' => 'blue', 'name' =>'joe');
$arr[2] = array('fruit' => 'peach', 'ver' => '2', 'color' => 'red', 'name' =>'jane');
$arr[3] = array('fruit' => 'apple', 'ver' => '1', 'color' => 'red', 'name' =>'jack');
$arr[4] = array('fruit' => 'apple', 'ver' => '4', 'color' => 'grey', 'name' =>'joe');
array2 =>
$arr[1] = array('fruit' => 'apple', 'ver' => '4', 'color' => 'red', 'name' =>'joe');
$arr[2] = array('fruit' => 'apple', 'ver' => '4', 'color' => 'red', 'name' =>'jane');
I need to match 2 key values, in this example only return the matches in array1 that match array2. The key values for example are the keys
fruit
and name
.
In the above example you can see this match should only return $arr1
and $arr4
for array1
since they match $arr[1]
in array2
. I need to return the matches only for array1.
This is an example, the real case I do not know the array varibale indicator or the amount ( likely a few hundred in each).