public function join($glue, $finalGlue = '')
    {
        if ($finalGlue === '') {
            return $this->implode($glue);
        }

        $count = $this->count();

        if ($count === 0) {
            return '';
        }

        if ($count === 1) {
            return $this->last();
        }

        $collection = new static($this->items);

        $finalItem = $collection->pop();

        return $collection->implode($glue).$finalGlue.$finalItem;
    }
public function join($glue, $finalGlue = '')
    {
        if ($finalGlue === '') {
            return $this->implode($glue);
        }

        $count = $this->count();

        if ($count === 0) {
            return '';
        }

        if ($count === 1) {
            return $this->last();
        }

        $collection = new static($this->items);

        $finalItem = $collection->pop();

        return $collection->implode($glue).$finalGlue.$finalItem;
    }
public function join ( $ glue , $ finalGlue = '' ) { if ( $ finalGlue === '' ) { return $ this -> implode ( $ glue ) ; } $ count = $ this -> count ( ) ; if ( $ count === 0 ) { return '' ; } if ( $ count === 1 ) { return $ this -> last ( ) ; } $ collection = new static ( $ this -> items ) ; $ finalItem = $ collection -> pop ( ) ; return $ collection -> implode ( $ glue ) . $ finalGlue . $ finalItem ; }
Join all items from the collection using a string. The final items can use a separate glue string.

@param  string  $glue
@param  string  $finalGlue
@return string
Join all items from the collection using a string . The final items can use a separate glue string .