PHP substr_replace()


substr_replace() function replace a specified substring with another string.

<?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
?>

substr_replace() also supports negative numbers.
<?PHP
	$str="The best time is no time at that time";
    echo substr_replace($str,"dime",-13);  //The best time is no timedime
?>