如何有效地检查一行中关联数组是否具有某些键(并且这是唯一的键)?
像
这样的东西function validate(array $data): bool
{
return
count(array_intersect_key(
$data,
['key_1' => true, 'key_2' => true, 'key_3' => true]
)) === 3
&& count($data) === 3;
}