验证数组之间的键/值对

I have a "master" array, and several arrays I have to verify against the master.

The master array is a list of key/value pairs. The other arrays have to be made of some (or all) of these pairs, nothing else.

Here is some example to clarify:

$master = [1=>'foo', 2=>'bar', 3=>'baz'];
$good_child = [2=>'bar'];
$wrong_child_1 = [2=>'sparta'];
$wrong_child_2 = [42=>'bar'];

Currently I'm doing the verification with this quick piece of code:

foreach ($child as $key => $value) {
    if ($master[$key] !== $value) {
        // wrong child
    }
}

You already may have noticed it would fail with the $wrong_child_2 above (undefined index), although it's not a problem in the real application (at least for now).

My question is, would there be a better way to make these verifications? Preferably without loops, rather array functions.

Have a look at array_diff_assoc.

$bad = (bool)count(array_diff_assoc($test_array, $master_array))

In other words, $test_array does not validate if there are any differences, including the index check.