Should you want a similar function for splicing strings together, here is a rough equivalent:
<?php
function str_splice($input, $offset, $length=null, $splice='')
{
$input = (string)$input;
$splice = (string)$splice;
$count = strlen($input);
if ($offset<0) $offset = $count + $offset;
if (is_null($length)) $length = $count;
elseif ($length < 0) $length = $count-$offset+$length;
return substr($input, 0, $offset) . $splice . substr($input, $offset+$length);
}
$string = "The fox jumped over the lazy dog.";
echo str_splice($string, 4, 0, "quick brown ");
?>
Obviously this is not for cases where all you need to do is a simple search-and-replace.