php8.5
Home/ Manual/ ds / vector/ Ds\Vector::join

Ds\Vector::join

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Joins all values together as a string

Description

Ds\Vector::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 vector joined together as a string.

Examples

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

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

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

The above example will output something similar to:

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

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

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

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

The above example will output something similar to:

output
string(6) "abc123"

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