PHP string replacement with str_replace function

You can replace a character, a word or even a string from a string through str_replace function in PHP. str_replace function required three string parameter to make replacement on the string first parameter old string which you want to replace and second parameter is new string with you want to replace old string and third and last parameter is whole string. The example of replace method is mentioned below: Code


<?php
  $greetingStr = "Good Morning";
  $result =str_replace("Morning", "Evening", $greetingStr);
?>
In above mentioned example we have a string variable with the name of $greetingStr and we make a replacement with str_replace method, we replace 'Morning' with 'Evening'.