By supplying no start or length arguments, the string will be added to the beginning : substr_replace « String « PHP






By supplying no start or length arguments, the string will be added to the beginning

 
<?php

  $mystring = substr_replace("Hello World", "H3110 W0r1d!", 0, 0);
  echo $mystring . "<br />"; //Echos H3110 W0r1d!Hello World
  
  $mystring = substr_replace("Hello World", "0 w0", 4, 4);
  echo $mystring; //Echos Hell0 w0rld.
  
?>
  
  








Related examples in the same category

1.PHP has two main functions for performing simple search-and-replace operations. The first one is substr_replace
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