src/StringBuilder.php
public function insert($offset, $string)
    {
        $offset = (int) $offset;
        $string = static::convertString($string, $this->encoding);

        if ($offset < 0 || $offset >= $this->length()) {
            throw new \OutOfBoundsException();
        }

        $this->string = mb_substr($this->string, 0, $offset, $this->encoding) .
            $string .
            mb_substr($this->string, $offset, $this->length(), $this->encoding);
        return $this;
    }
public function insert($offset, $string)
    {
        $offset = (int) $offset;
        $string = static::convertString($string, $this->encoding);

        if ($offset < 0 || $offset >= $this->length()) {
            throw new \OutOfBoundsException();
        }

        $this->string = mb_substr($this->string, 0, $offset, $this->encoding) .
            $string .
            mb_substr($this->string, $offset, $this->length(), $this->encoding);
        return $this;
    }
public function insert ( $ offset , $ string ) { $ offset = ( int ) $ offset ; $ string = static :: convertString ( $ string , $ this -> encoding ) ; if ( $ offset < 0 || $ offset >= $ this -> length ( ) ) { throw new \ OutOfBoundsException ( ) ; } $ this -> string = mb_substr ( $ this -> string , 0 , $ offset , $ this -> encoding ) . $ string . mb_substr ( $ this -> string , $ offset , $ this -> length ( ) , $ this -> encoding ) ; return $ this ; }
Insert a string into the sequence.

@param int    $offset The offset index.
@param string $string The sequence to insert.

@return StringBuilder

@throws \OutOfBoundsException If the index is out of bounds.
Insert a string into the sequence .