<?PHP
$str="The best time is no time at that time";
echo substr_replace($str,"dime",9,4); //The best dime is no time at that time
?>
If no length is specified, the function replaces the substring from the offset till the end of string.
<?PHP
$str="The best time is no time at that time";
echo substr_replace($str,"dime", 9); //The best dime
?>
<?PHP
$str="The best time is no time at that time";
echo substr_replace($str,"dime",-13); //The best time is no timedime
?>