PHP has two main functions for performing simple search-and-replace operations. The first one is substr_replace : substr_replace « String « PHP






PHP has two main functions for performing simple search-and-replace operations. The first one is substr_replace

 
<?php

    $haystack = 'this is a test';
    $newstr = substr_replace ($haystack, 'sad', 6, 5); 
    echo "$newstr\n";

?>
  
  








Related examples in the same category

1.By supplying no start or length arguments, the string will be added to the beginning
2.Replacing Substrings: string substr_replace ( string str, string replacmnt, int start [, int len] )
3.Replacing a Portion of a String Using substr_replace()
4.Replacing a substring with substr_replace()
5.substr_replace() function replaces the string with replacement.
6.substr_replace.php