This function returns a string or an array with all occurrences of $search in $subject replaced with the given $replace value.

If you don't need fancy replacing rules (like regular expressions), you should always use this function instead of ereg_replace() or preg_replace().

declaration of str_replace

string str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

test str_replace online

share str_replace

comments for str_replace

On 23. May 2012 09:40 ankit wrote:

Nice Approach of yours....thanks

On 01. Nov 2011 19:44 butzi wrote:

@Dave: It is not a problem of the escape, it is a problem of the string delimiter ' instead of ". Double-Quotes are a to great risk for such a site.

On 12. Oct 2011 11:24 Dave wrote:

The $search value is unintentionally being escaped - so you can't use \n or \t etc, which would otherwise be valid.

more comments for str_replace

There are some more comments for str_replace(). To see them all click here.


Leave your comment