PHP ereg_replace deprecated

FFish picture FFish · Nov 19, 2010 · Viewed 11.7k times · Source

I have a script that throws me errors because I run PHP 5.3.1
What Do I have to use in the example?

$row[$j] = ereg_replace("\n", "\\n", $row[$j]);

Deprecated: Function ereg_replace() is deprecated in..

Answer

Jim picture Jim · Nov 19, 2010

Use preg_replace instead, just add delimiters.

$row[$j] = preg_replace("#\n#", "\\n", $row[$j]);