Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP ereg_replace deprecated [duplicate]

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..

like image 420
FFish Avatar asked Nov 19 '10 14:11

FFish


2 Answers

Use preg_replace instead, just add delimiters.

$row[$j] = preg_replace("#\n#", "\\n", $row[$j]);
like image 138
Jim Avatar answered Sep 30 '22 06:09

Jim


Use the preg_replace function instead.

like image 45
Marc B Avatar answered Sep 30 '22 04:09

Marc B