Makes replacements using regular expressions.
This function has been deprecated as of PHP 5.3.0.
ereg_replace() replaces the occurrences of the pattern with the replacement string. The resulting string is returned. Submatches can be accessed in the replacement with backslashes.
<pre>
<?php
$s = "Coding PHP is fun.";
$pattern = "(.*)PHP(.*)";
$replacement = " They say \\1other languages\\2";
print ereg_replace($pattern, $replacement, $s);
?>
</pre>
They say Coding other languages is fun.
"PHP" is replaced with "other languages", and the sentence is changed a little, using \1 and \2 to access the parts within parentheses.