Implode an array to a string.

@return ExpressionFunction
165568
protected function createImplodeFunction()
    {
        return new ExpressionFunction(
            'implode',
            function ($glue, $pieces) {
                return sprintf('implode(%s,%s)', $glue, $pieces);
            },
            function ($arguments, $glue, $pieces) {
                return implode($glue, $pieces);
            }
        );
    }
37026
public function serialize()
    {
        $text = array();
        foreach ($this->parameters as $k => $v) {
            $text[] = $k . ': ' . $v;
        }
        foreach ($this->variables as $k => $v) {
            $text[] = 'Set: ' . $k . '=' . $v;
        }
        return implode("\n", $text);
    }
1085838
static function escape_string($str)
    {
        if (is_array($str) && count($str) > 1) {
            foreach ($str as $idx => $val)
                $str[$idx] = self::escape_string($val);

            return '[' . implode(',', $str) . ']';
        }
        else if (is_array($str)) {
            $str = array_pop($str);
        }

        // multi-line string
        if (preg_match('/[\r\n\0]/', $str)) {
            return sprintf("text:\n%s\n.\n", self::escape_multiline_string($str));
        }
        // quoted-string
        else {
            return '"' . addcslashes($str, '\\"') . '"';
        }
    }
966414
public function encode()
    {
    	foreach ($this->body as $key => $value) {
    		$result[] = $this->replaceText($value);
    	}

    	return implode('', $result);
    }
111740
protected function implodeParams(array $params)
    {
        $s = '';

        foreach ($params as $header => $value) {
            $s .= trim($header) . ": " . trim($value) . "\r\n";
        }

        return $s;
    }
25293
public function toString()
    {
        $matchToString = function ($key, $value) {
            return ' "' . $key . '" is "' . $value . '"';
        };

        $matchesToString = function ($matches) use ($matchToString) {
            $matchesAsString = implode(' and ', array_map(
                $matchToString,
                array_keys($matches),
                array_values($matches)
            ));

            return '(' . $matchesAsString . ')';
        };

        $allMatchesAsString = implode(
            "\n or ",
            array_map($matchesToString, $this->matches)
        );


        return $this->getStubForToString() . $allMatchesAsString;
    }
177563
public static function toString()
    {
        $return = [];

        foreach (static::$globals as $key => $value) {
            $type = gettype($value);

            if (is_callable($value)) {
                $valueString = 'callable';
                $type = 'callable';
            } elseif (is_array($value)) {
                $valueString = implode(', ', $value);
            } else {
                $valueString = (string)$value;
            }

            $return[] = sprintf(
                '"%s": (%s) %s',
                $key,
                $type,
                $valueString
            );
        }

        return implode(PHP_EOL, $return);
    }
1093868
static public function stringify(array $array)
    {
        $result = array();
        foreach ($array as $key => $value) {
            $result[] = sprintf('%s=%s', $key, $value);
        }
        return implode('&', $result);
    }
567908
public function render()
    {
        $html = [];

        foreach ($this->all() as $key => $value) {
            if (is_null($value)) {
                continue;
            }

            if (is_numeric($key)) {
                $key = $value;
            }

            $html[] = $key . '="' . e($value) . '"';
        }

        return implode(' ', array_filter($html));
    }
1066478
public static String implode(int[] values, String separator) {
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < values.length; i++) {
            if (i > 0)
                result.append(separator);
            result.append(values[i]);
        }
        return result.toString();
    }
769764
protected function toStringFunction()
    {
        $string = ($this->isFinal() ? 'final ' : '')
            . ($this->isAbstract() ? 'abstract ' : '')
            . $this->getVisibility() . ' '
            . ($this->isStatic() ? 'static ' : '')
            . 'function ';

        return $string;
    }
991728
public function toString()
    {
        $constraints = [];
        foreach ($this->constraints as $name=>$constraint) {
            $constraints[] = "$constraint";
        }
        return implode($this->toStringSeparator, $constraints);
    }
439876
function toString( $contentObjectAttribute )
    {
        $matrix = $contentObjectAttribute->attribute( 'content' );
        $matrixArray = array();
        $rows = $matrix->attribute( 'rows' );

        foreach( $rows['sequential'] as $row )
        {
            $matrixArray[] = eZStringUtils::implodeStr( $row['columns'], '|' );
        }

        return eZStringUtils::implodeStr( $matrixArray, '&' );

    }
1082055
public function reduce($array)
    {
        $tokens = array();

        foreach($array as $a){
            $tokens[] = $this->quote($this->escape($a));
        }

        return $tokens ? '('.implode(',', $tokens).')' : '(null)';
    }
953893
public static function toString(array $array, string $delimiter = ', '): string
    {
        if (!$array) {
            return '';
        }

        foreach ($array as $key => $value) {
            if (!$value) {
                unset($array[$key]);
            }
        }

        return implode($delimiter, $array);
    }
217085
public function getString($value)
    {
        if (is_array($value)
            || $value instanceof \Iterator) {
            return '';
        }
        if ($value instanceof Collection) {
            $value = $value->toArray();
        }
        return implode(',', $value);
    }
939166
public static function implode($array, $separator = " > ")
    {
        if ($array === null) {
            return "";
        }

        $elements = [];
        foreach($array as $rawElement) {
            $element = self::sanitizeString($rawElement);

            if ($element !== null) {
                $elements[] = $element;
            }
        }

        return implode($separator, $elements);
    }