public static function arrayMergeIgnoreCase() {
    if (func_num_args() < 2) {
      throw new \InvalidArgumentException(
          "At least two arrays must be supplied.");
    }
    $result = [];
    $key_mapping = [];
    $input_args = func_get_args();

    foreach($input_args as $args) {
      if (!is_array($args)) {
        throw new \InvalidArgumentException(
            "Arguments are expected to be arrays, found " . gettype($arg));
      }
      foreach($args as $key => $val) {
        $lower_case_key = strtolower($key);
        if (array_key_exists($lower_case_key, $key_mapping)) {
          $result[$key_mapping[$lower_case_key]] = $val;
        } else {
          $key_mapping[$lower_case_key] = $key;
          $result[$key] = $val;
        }
      }
    }
    return $result;
  }