Function ereg_replace() is deprecated - How to clear this bug?

Pradip picture Pradip · Jun 28, 2010 · Viewed 178.6k times · Source

I have written following PHP code:

$input="menu=1&type=0&";

print $input."<hr>".ereg_replace('/&/', ':::', $input);

After running above code, it gives following warning,

Deprecated: Function ereg_replace() is deprecated

How can I resolve this warning.

Answer

Quentin picture Quentin · Jun 28, 2010

Switch to preg_replaceDocs and update the expression to use preg syntax (PCRE) instead of ereg syntax (POSIX) where there are differencesDocs (just as it says to do in the manual for ereg_replaceDocs).