Stringy\Stringy::insert PHP Метод

insert() публичный метод

Inserts $substring into the string at the $index provided.
public insert ( string $substring, integer $index ) : Stringy
$substring string String to be inserted
$index integer The index at which to insert the substring
Результат Stringy Object with the resulting $str after the insertion
    public function insert($substring, $index)
    {
        $stringy = static::create($this->str, $this->encoding);
        if ($index > $stringy->length()) {
            return $stringy;
        }
        $start = \mb_substr($stringy->str, 0, $index, $stringy->encoding);
        $end = \mb_substr($stringy->str, $index, $stringy->length(), $stringy->encoding);
        $stringy->str = $start . $substring . $end;
        return $stringy;
    }