src/Text.php
public function insert($substring, $index) {
		if ($index <= 0) {
			return $this->prepend($substring);
		}

		if ($index > $this->length()) {
			return $this->append($substring);
		}

		$start = mb_substr($this->string, 0, $index, $this->encoding);
		$end = mb_substr($this->string, $index, $this->length(), $this->encoding);
		return new Text($start . $substring . $end);
	}
public function insert($substring, $index) {
		if ($index <= 0) {
			return $this->prepend($substring);
		}

		if ($index > $this->length()) {
			return $this->append($substring);
		}

		$start = mb_substr($this->string, 0, $index, $this->encoding);
		$end = mb_substr($this->string, $index, $this->length(), $this->encoding);
		return new Text($start . $substring . $end);
	}
public function insert ( $ substring , $ index ) { if ( $ index <= 0 ) { return $ this -> prepend ( $ substring ) ; } if ( $ index > $ this -> length ( ) ) { return $ this -> append ( $ substring ) ; } $ start = mb_substr ( $ this -> string , 0 , $ index , $ this -> encoding ) ; $ end = mb_substr ( $ this -> string , $ index , $ this -> length ( ) , $ this -> encoding ) ; return new Text ( $ start . $ substring . $ end ) ; }
Inserts a substring at the given index

<code>
$str = new Text('Hello World!');<br>
$str->insert('to this ', 5); // Hello to this World!
</code>

@param string|Text $substring
@param int $index
@return Text
Inserts a substring at the given index