public static function implodeDelim($values, $char = ',')
    {
        if (\is_array($char)) {  // params were originally swapped
            list($values, $char) = array($char, $values);
        }
        if (empty($values)) {
            return '';
        }
        $str = '';
        foreach ($values as $k => $v) {
            if ($char == ',') {
                $v = \str_replace('"', '""', $v);
            }
            if (\preg_match('/['.$char.'\n"]/', $v)) {
                $v = '"'.$v.'"';
            }
            $values[$k] = $v;
        }
        $str = \implode($char, $values);
        return $str;
    }