str_replace

string str_replace(string find, string replace, string string) 

Replaces all occurrences of find within string with replace.

Returns:

String

Description:

str_replace() replaces all instances of find within string with replace .

Version:

PHP 3.0.6+, PHP 4+

See also:

Other methods of replacing characters in a string:

str_replace() 
strtr() 

The regular expression functions

Example:

Remove all instances of (q.v.)
<?php 
$string = "For more on frobjigget mangling, see frobnagle() (q.v.)."; 
echo str_replace (' (q.v.)', '', $string); 
?> 

Output: 
For more on frobjigget mangling, see frobnagle(). 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.