I have taken 2 text boxes and 1 text area
User will be to search the content through search box
and provides by which word it should be replaced.

Scenerio 1 :

I want to replace "Good" with word "bad"  

But this code does not replace the text area content.
It rather appends with the new replaced string

what's the solution ??

```
<body>

<form id="form1" name="form1" method="post" action="">

<p>
<label for="search">Search :</label>
<input type="text" name="search" id="search" />
</p>

<p>
<label for="replace">Replace</label>
<input type="text" name="replace" id="replace" />
</p>

<p><Br />
<input type="submit" name="submit" id="submit" value="Submit" />
<label for="textarea"></label>
</p>

<p><br />
<textarea name="textarea" id="textarea" cols="45" rows="5"  >
"Good morning how are you today are you feeling Good.";
<?php

if(isset($_POST["submit"]))
{
     $search = $_POST["search"];
 $replace = $_POST["replace"];
 $textarea = $_POST["textarea"];

 $newtext = str_replace($search,$replace,$textarea);
     echo $newtext;

}

?>
   </textarea>
  </p>
</form>

</body>
</html>

```
['https://Stackoverflow.com/questions/9480338', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1361058/']
What about [the Intl Twig extension](https://github.com/fabpot/Twig-extensions/blob/master/lib/Twig/Extensions/Extension/Intl.php)?

Usage in a twig template:

```
{{ my_date | localizeddate('full', 'none', locale) }}

```
I didn't want to install a whole extensions just for this stuff and need to do a few things automatically: It's also possible to write a helperclass (or expand an existing helper) in Bundle/Twig/Extensions for example like this:

```
public function foo(\Datetime $datetime, $lang = 'de_DE', $pattern = 'd. MMMM Y')
{
    $formatter = new \IntlDateFormatter($lang, \IntlDateFormatter::LONG, \IntlDateFormatter::LONG);
    $formatter->setPattern($pattern);
    return $formatter->format($datetime);
}

```

twig-Template:

```
{{ yourDateTimeObject|foo('en_US', 'd. MMMM Y') }}

```

The result is "12. February 2014" (or "12. Februar 2014" in de\_DE and so on)