<?php
function replaceStrAt($str, $substr, $from, $to = null){
is_null($to) and $to = $from;
return mb_substr($str, 0, $from) . $substr . mb_substr($str, $to + 1);
}
function insertSubstrInto($str, $substr, $index){
return mb_substr($str, 0, $index) . $substr . mb_substr($str, $index);
}
$s = 'И просто текст';
echo replaceStrAt($s, "\t", 4), "\n";
echo insertSubstrInto($s, "\t", 4), "\n";
preferences:
32.9 ms | 404 KiB | 5 Q