Qaribou\Collection\ImmArray::join PHP Method

join() public method

Join a set of strings together.
public join ( string $token = ',', string $secondToken = null ) : string
$token string Main token to put between elements
$secondToken string If set, $token on left $secondToken on right
return string
    public function join($token = ',', $secondToken = null)
    {
        $ret = '';
        if ($secondToken) {
            foreach ($this as $el) {
                $ret .= $token . $el . $secondToken;
            }
        } else {
            $this->rewind();
            while ($this->valid()) {
                $ret .= (string) $this->current();
                $this->next();
                if ($this->valid()) {
                    $ret .= $token;
                }
            }
        }
        return $ret;
    }