Skip to content

Look up an array key

Return the value for a key, with an optional case-insensitive variant.

18th August 2026

function array_key_search($haystack, $needle)
{
    if (isset($haystack["$needle"])) {
        return $haystack["$needle"];
    }
    return null;
}

function array_key_isearch($haystack, $needle)
{
    $haystack = array_change_key_case($haystack, CASE_LOWER);
    $needle = strtolower($needle);

    return array_key_search($haystack, $needle);
}