0

I am learning PHP functions and have this problem:

I need to change the function *ereg_replace*

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

to *preg_replace*

how to do it ?

Thank you

Ing. Michal Hudak
  • 5,010
  • 9
  • 57
  • 90

1 Answers1

2

Well, this is not a regular expression that you are using. What you want here is str_replace.

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

Rather read up about what regular expressions are and how they work.

Richard
  • 4,183
  • 5
  • 31
  • 52