Replacing Substrings Using str_replace() : str_replace « String « PHP






Replacing Substrings Using str_replace()

 
str_replace() replaces all instances of a string within another string. 


<?php
    $string = "Site contents copyright 2003.";
    $string .= "The 2003 Guide";
    print str_replace("2003","2004",$string);
?>
  
  








Related examples in the same category

1.str_replace demo
2.str_replace() accepts arrays for all its arguments
3.str_replace() function searches for occurrence in string, replacing all instances with replacement.
4.str_replace.php
5.Using str_replace()
6.mixed str_replace ( mixed needle, mixed replace, mixed haystack [, int &count] )
7.Replacing Tabs with Spaces
8.case-sensitive?
9.Using template file
10.Switching tabs and spaces