PHP str_replace Function

The str_replace function in PHP is used to change certain occurrances on a string with a replacement string. The syntax of the str_replace function is:

str_replace ('match_pattern', 'replacement_pattern', 'text', [count])

The parameter match_pattern is the match to look for. replacement_pattern is the replacement string to use. Both match_pattern and replacement_pattern can be of several data types (not limited to strings). text is the initial string. The optional parameter count is used to count the number of matches to replace.