public static function assoc_to_keyval($assoc, $keyField, $valField)
    {
        if (!is_array($assoc) and ! $assoc instanceof Iterator) {
            throw new InvalidArgumentException('The first parameter must be an array.');
        }
        $output = [];
        foreach ($assoc as $row) {
            if (isset($row[$keyField]) and isset($row[$valField])) {
                $output[$row[$keyField]] = $row[$valField];
            }
        }
        return $output;
    }