Example
Replace "Hello" with "world":
<?php echo substr_replace("Hello","world",0); ?>
Definition and usage
substr_replace() function replaces the string Replace part of it with another string.
Note: If the start parameter is negative and length is less than or equal to start, length is 0.
Note: This function is binary safe.
Syntax
substr_replace(string,replacement,start,length)
Parameters | Description |
string | Required. Specifies the string to check. |
replacement | Required. Specifies the string to be inserted. |
start | Required. Specifies where in the string to begin replacement.
|
length | Optional. Specifies how many characters to replace. The default is the same as the string length.
|
Technical details
Return value: | Return the replaced string. If string is an array, the array is returned. |
PHP Version: | 4+ |
##Update Log : | As of PHP 4.3.3, all parameters accept arrays.