Miscellany
public text v1 · immutable function replace_at_pos(&$text, $pos, $previous, $with, $addpos = 0) {
if (!is_int($previous))
$previous = strlen($previous);
$previous += $addpos;
$text = substr($text, 0, $pos) . $with . substr($text, $pos+$previous);
return strlen($with) - $previous;
}