Check if array key exists, case insensitive

Viewed 3995

I try to find the right way to check, in a CASE-INSENSITIVE manner, if an array key exists.

I have an array - a list of HTTP headers:

$headers = [
    'User-Agent' => 'Mozilla',
];

Basically, I want to be able to give something like this (with small character 'u'):

$keyExists = array_key_exists('user-Agent', $headers);

and to receive a boolean true when applying a var_dump:

var_dump($keyExists); // I need TRUE to be returned.

Thank you for your help.

3 Answers
Related