So, what exactly is the difference between ereg_replace and eregi_replace?
Ever asked yourself what the difference is between functions that start with the term ereg and eregi? After all, both search through strings by using regular expression patterns. Both either return true or false and pass on groups in arrays of regs (ereg and eregi), or perform a replacement in the specified location without changing the original (ereg_replace and eregi_replace).
The difference, as per usual, is far closer at hand. While ereg and ereg_replace distinguish between letters in lower case and capitols, eregi and eregi_replace do not. To put this to the test we can use the following code:
$string = "abc";
echo "ereg(\"abc\"): ".ereg("abc", $string)."<br>";
echo "eregi(\"abc\"): ".eregi("abc", $string)."<br>";
echo "ereg(\"ABC\"): ".ereg("ABC", $string)."<br>";
echo "eregi(\"ABC\"): ".eregi("ABC", $string)."<br>";
On the third line ereg("ABC", $string) should return NULL, as $string contains abc in lowercase letters.
There you have it then. If you require a string search that excludes lower or upper case versions of specified letters, a simple ereg is what you are after. If however your function is more open regarding capitals and lower case letters you can by all means use eregi. The important part is that you know the difference between the two and can therefore build your regular expressions accordingly!