php8.5
Home/ Manual/ ds / sequence/ Ds\Sequence::join

Ds\Sequence::join

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Joins all values together as a string

Description

Ds\Sequence::join([string $glue]): string

Joins all values together as a string using an optional separator between each value.

Parameters

glue

An optional string to separate each value.

Return Values

All values of the sequence joined together as a string.

Examples

Ds\Sequence::join() example using a separator string

php
<?php
$sequence = new \Ds\Vector(["a", "b", "c", 1, 2, 3]);

var_dump($sequence->join("|"));
?>

The above example will output something similar to:

output
string(11) "a|b|c|1|2|3"

Ds\Sequence::join() example without a separator string

php
<?php
$sequence = new \Ds\Vector(["a", "b", "c", 1, 2, 3]);

var_dump($sequence->join());
?>

The above example will output something similar to:

output
string(11) "abc123"

Source: reference/ds/ds/sequence/join.xml · from the official PHP manual (php/doc-en)