<?php
$arrays = [
[
'foo' => 'bar',
'bar' => 'baz',
'baz' => 'foo',
],
[
'foo' => 'bar',
'baz' => 'foo',
],
[
'foo' => 'bar',
'bar' => 'baz',
],
];
function check_keys(array $input, array $keys)
{
return array_intersect($keys, array_keys($input)) === $keys;
}
var_dump(check_keys($arrays[0], ['foo', 'baz', 'bar']));
var_dump(check_keys($arrays[1], ['foo', 'baz']));
var_dump(check_keys($arrays[2], ['foo', 'bar']));
var_dump(check_keys($arrays[2], ['baz', 'bar']));
bool(true)
bool(true)
bool(true)
bool(false)