I have Array #1 which contains:
Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => large
)
I have Array #2 which contains:
Array
(
[4624] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => large
)
[4625] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => medium
)
[4626] => Array
(
[attribute_pa_color] => blue
[attribute_pa_size] => small
)
)
How can I find the array key from Array #2 where the inner keys and values match Array 1's?
I have been experimenting with multiple foreach's but I can't seem to get this right, this is my current idea:
$i = 0;
foreach( $array_2 as $array2_key => $array2_array ) {
foreach( $array2_array as $a2_key => $a2_value ) {
if( $a2_value == $array1[$a2key] ) {
$i = $i + 1;
if( $i == count( $array1 ) ) {
$break = 1;
}
if( $break == 1 ) {
break;
}
}
}
if( $break == 1 ) {
echo 'key is: ' . $array2_key;
break;
}
}