public static function filterCaseInsensitively(array $needles, array $haystack)
    {
        $result = array();
        $modifiedHaystack = array_change_key_case($haystack, CASE_LOWER);
        foreach ($needles as $needle) {
            $modifiedNeedle = strtolower($needle);
            if (array_key_exists($needle, $haystack)) {
                $result[$needle] = $haystack[$needle];
            } elseif (array_key_exists($modifiedNeedle, $modifiedHaystack)) {
                $result[$needle] = $modifiedHaystack[$modifiedNeedle];
            }
        }
        return $result;
    }