@param array  $items
@param string $delimiter
@param string $enclosure

@return string
433330
private function strToCSV(
        array $items,
        string $delimiter = ',',
        string $enclosure = '"'
    ) {
        $fp = fopen('php://temp', 'r+b');
        foreach ($items as $item) {
            fputcsv($fp, $item, $delimiter, $enclosure);
        }
        rewind($fp);
        $data = rtrim(stream_get_contents($fp), "\n");
        fclose($fp);

        return $data;
    }
902129
public function listBlobs($container, $prefix = '', $delimiter = '')
    {
        $allFiles = $this->gridFind();
        $return = [];
        foreach ($allFiles as $fileObj) {
            $return[] = $this->getBlobMeta($fileObj);
        }

        /** If we have a delimiter (directory), there is no method in GridFS library to get only records under
         * the delimiter as in AWS s3, so we need to manually filter out. First reduce down dirs to passed $prefix */
        $reduced = [];
        foreach ($return as &$filterBlob) {
            if (strpos($filterBlob['path'], $prefix) !== false) {
                $reduced[] = $filterBlob;
            }
        }

        if (empty($reduced) && !empty($prefix)) {
            return [];
        }

        $reduced = (empty($reduced)) ? $return : $reduced;

        return $this->filterPaths($prefix, $delimiter, $reduced);
    }
313037
public static function camelize(array $array, string $delimiter = '_', bool $lcfirst = true)
    {
        foreach ($array as $key => $value) {
            $k = $key;
            $k = Text::camelize($k);
            $lcfirst && $k = lcfirst($k);
            if ($key != $k) {
                unset($array[$key]);
            }
            if (is_array($value)) {
                $value = static::camelize($value, $delimiter, $lcfirst);
            }
            $array[$k] = $value;
        }
        return $array;
    }
420570
public function concat(array $values, string $delimiter = ''): string
    {
        if ($delimiter) {
            return implode(' + ' . $delimiter . ' + ', $values);
        }

        return implode(' + ', $values);
    }
834417
public static function remove(array& $array, string $key, string $delimiter = null)
    {
        // Which string delimiter should we use?
        if (!isset($delimiter)) {
            $delimiter = static::$delimiter;
        }

        // Explode the key according to that delimiter.
        $keys = explode($delimiter, $key);

        while ($key = array_shift($keys)) {
            if (!isset($array[$key]) || !is_array($array[$key])) {
                return;
            }

            $array =& $array[$key];
        }

        unset($array[array_shift($keys)]);
    }
435325
protected function coerceList($item, $delim = ',')
    {
        if (isset($item) && $item[0] === Type::T_LIST) {
            return $item;
        }

        if (isset($item) && $item[0] === Type::T_MAP) {
            $keys = $item[1];
            $values = $item[2];
            $list = [];

            for ($i = 0, $s = count($keys); $i < $s; $i++) {
                $key = $keys[$i];
                $value = $values[$i];

                $list[] = [
                    Type::T_LIST,
                    '',
                    [[Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))], $value]
                ];
            }

            return [Type::T_LIST, ',', $list];
        }

        return [Type::T_LIST, $delim, ! isset($item) ? []: [$item]];
    }
1061286
public function encode($data, $delimiter = null): string
    {
        if (count($data) === 0) {
            return '';
        }
        $delimiter = $delimiter ?? $this->getDelimiter();
        $header = array_keys(reset($data));

        // Encode the field names
        $string = implode($delimiter, $header). "\n";

        // Encode the data
        foreach ($data as $row) {
            $string .=  implode($delimiter, $row). "\n";
        }

        return $string;
    }
25518
public function explode($delimiter): array
    {
        Assert::typeOf(['string', __CLASS__], $delimiter);

        $response = [];
        $results  = explode((string) $delimiter, $this->data);

        if ($results === false) {
            throw new RuntimeException('An unknown error occurred while splitting string!');
        }

        foreach ($results as $result) {
            $response[] = new static($result, $this->encoding);
        }

        return $response;
    }
59812
public static function multiExplode($string, array $delimiters, $keepDelimiters = true)
    {
        if ($keepDelimiters === true) {
            // Ensure special characters are escaped
            foreach ($delimiters as &$delimiter) {
                $delimiter = preg_quote($delimiter);
            }

            // RegEx fragment with delimiters
            $fragment = implode('|', $delimiters);
            $regEx = sprintf('@(?<=%s)@', $fragment);
            return preg_split($regEx, $string, -1, PREG_SPLIT_DELIM_CAPTURE);

        } else {

            $string = str_replace($delimiters, $delimiters[0], $string);
            return explode($delimiters[0], $string);
        }
    }
260035
public function getParameterListAsObject($name, $delimiter = ";")
    {

        $parameter = $this->getValidParameterOfType($name, "string");
        $list = preg_split('/\s*(?:,*("[^"]+"),*|,*(\'[^\']+\'),*|,+)\s*/', $parameter, null,
            PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
        //if emptyparameter return throw an exception because they'd be expecting an object;


        $parameters = [];
        $values = [];

        foreach ($list as $itemValue) {
            //if items have qualities associated with them we shall sort the parameter array by qualities;
            $bits = preg_split('/\s*(?:;*("[^"]+");*|;*(\'[^\']+\');*|;+)\s*/', $itemValue, 0,
                PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
            $value = array_shift($bits);
            $attributes = [];

            $lastNullAttribute = null;
            foreach ($bits as $bit) {
                if (($start = substr($bit, 0, 1)) === ($end = substr($bit, -1))
                    && ($start === '"'
                        || $start === '\'')
                ) {
                    $attributes[$lastNullAttribute] = substr($bit, 1, -1);
                } elseif ('=' === $end) {
                    $lastNullAttribute = $bit = substr($bit, 0, -1);
                    $attributes[$bit] = null;
                } else {
                    $parts = explode('=', $bit);
                    $attributes[$parts[0]] = isset($parts[1]) && strlen($parts[1]) > 0 ? $parts[1] : '';
                }
            }

            $parameters[($start = substr($value, 0, 1)) === ($end = substr($value, -1)) && ($start === '"' || $start === '\'')
                ? substr($value, 1, -1) : $value] = $attributes;

        }

        return new Factory($name, $parameters, static::$sanitizer, static::$validator, false);
    }
29633
public static function getValueByPath(array $array, string $path, string $delimiter = '/')
    {
        $path = trim($path, $delimiter);
        $keys = $path ? explode($delimiter, $path) : [];
        $value = $array;
        foreach ($keys as $key) {
            $value = $value[$key];
        }

        return $value;
    }
327020
protected function _enclose_value($value = null, $delimiter) {
        if ($value !== null && $value != '') {
            $delimiter_quoted = $delimiter ?
                preg_quote($delimiter, '/') . "|"
                : '';
            $enclosure_quoted = preg_quote($this->enclosure, '/');
            $pattern = "/" . $delimiter_quoted . $enclosure_quoted . "|\n|\r/i";
            if ($this->enclose_all || preg_match($pattern, $value) || ($value{0} == ' ' || substr($value, -1) == ' ')) {
                $value = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $value);
                $value = $this->enclosure . $value . $this->enclosure;
            }
        }

        return $value;
    }
563831
public function toCsv($data = null, $delimiter = null)
	{
		// csv format settings
		$newline = Arr::get($this->config, 'csv.newline', "\n");
		$delimiter or $delimiter = Arr::get($this->config, 'csv.delimiter', ',');
		$enclosure = Arr::get($this->config, 'csv.enclosure', '"');
		$escape = Arr::get($this->config, 'csv.escape', '\\');

		// escape function
		$escaper = function($items) use($enclosure, $escape) {
			return array_map(function($item) use($enclosure, $escape){
				return str_replace($enclosure, $escape.$enclosure, $item);
			}, $items);
		};

		if ($data === null)
		{
			$data = $this->data;
		}

		if (is_object($data) and ! $data instanceof \Iterator)
		{
			$data = $this->toArray($data);
		}

		// Multi-dimensional array
		if (is_array($data) and Arr::isMulti($data))
		{
			$data = array_values($data);

			if (Arr::isAssoc($data[0]))
			{
				$headings = array_keys($data[0]);
			}
			else
			{
				$headings = array_shift($data);
			}
		}
		// Single array
		else
		{
			$headings = array_keys((array) $data);
			$data = array($data);
		}

		$output = $enclosure.implode($enclosure.$delimiter.$enclosure, $escaper($headings)).$enclosure.$newline;

		foreach ($data as $row)
		{
			$output .= $enclosure.implode($enclosure.$delimiter.$enclosure, $escaper((array) $row)).$enclosure.$newline;
		}

		return rtrim($output, $newline);
	}
1102773
public function toString($delimiter = ',')
    {
        $result = [];
        array_walk_recursive($this->attributes, function($v) use (&$result) {
            $result[] = $v;
        });

        return \implode($delimiter, $result);
    }
201681
public function join(array $array, string $separator = ','): string
    {
        $result = '';

        foreach ($array as $item) {
            if (is_array($item)) {
                $result .= $this->join($item, $separator) . $separator;
            } else {
                $result .= $item . $separator;
            }
        }

        $result = substr($result, 0, 0 - strlen($separator));

        return $result;
    }
958395
public static function arrayToString(array $array, $delimiter = ""): string {
        $string = "";
        foreach ($array as $value) {
            if (\is_array($value)) {
                $string .= ArrayUtil::arrayToString($value, $delimiter) . $delimiter;
            } else {
                $string .= $value . $delimiter;
            }
        }
        return $string;
    }
369419
public static function explode($string, $delimiter)
    {
        if (!String::isValid($string) ||
            String::isEmpty($string)) {
            return false;
        }

        return explode($delimiter, $string);
    }