substr_replace() function replaces the string with replacement. : substr_replace « String « PHP






substr_replace() function replaces the string with replacement.

 
Its syntax is: string substr_replace (string string, string replacement, int start [, int length])

If start is positive, replacement starts at character start.
If start is negative, replacement starts at (string length - start).
If length is positive, replacement will be length characters long.
If length is negative, replacement will end at (string length - length) characters.

<?
$favs = "is good";
$name = "A";
$favs = substr_replace($favs, $name, 0, 0);
print $favs;
?>
  
  








Related examples in the same category

1.By supplying no start or length arguments, the string will be added to the beginning
2.PHP has two main functions for performing simple search-and-replace operations. The first one is substr_replace
3.Replacing Substrings: string substr_replace ( string str, string replacmnt, int start [, int len] )
4.Replacing a Portion of a String Using substr_replace()
5.Replacing a substring with substr_replace()
6.substr_replace.php