How to replace strings or tags inside content in WordPress?

With wordpress is pretty easy to filter and replace tags that occur inside the content. Lets say you have the content with <php> tags and want to replace it as <pre> tag. All you need to do is write a filter in your theme file <strong>function.php</strong> ,that finds and replaces all occurrences of

php tags, which is so easy. Here is a snippet of code that does that, applying filter to the_content

function replace_my_tags() {
$content = get_the_content();
$content = ereg_replace('<php>','<pre>',$content);
$content = ereg_replace('</php>','</pre>',$content);
return $content; 
}
add_filter('the_content','replace_my_tags');

// This will replace all occurences of
to <pre> and </pre> tags.