当您想检查多个数组键时
<?php
$array = [];
$array['a'] = '';
$array['b'] = '';
$array['c'] = '';
$array['d'] = '';
$array['e'] = '';
// 所有给定的键 a,b,c 都存在于提供的数组中
var_dump(array_keys_exists(['a','b','c'], $array)); // bool(true)
function array_keys_exists(array $keys, array $array): bool
{
$diff = array_diff_key(array_flip($keys), $array);
return count($diff) === 0;
}