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,338
  • 11
  • 60
  • 91

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,341
  • 5
  • 35
  • 55