0

I try to modify a sql file created by mysqldump to import it to a SQLite database. Here I have already asked how to do this and got the answer that I have to replace e.g. "\r\n" with a new line.

Well, my question on the mentioned answer is whether and how is it possible to put a real line break into a string with PHP.

Example: Input: "Nice sentence. Also a nice sentence."

Output: "Nice sentence.

Also a nice sentence."

Community
  • 1
  • 1
HamuSumo
  • 41
  • 1
  • 5
  • Lots of examples http://stackoverflow.com/questions/7098488/problem-replacing-literal-string-r-n-with-line-break-in-php?rq=1 – gpdaniels Jul 09 '14 at 14:10

1 Answers1

0
// Note: $source is assigned with single quotes, which means that
// the \r\n will not be interpolated
$source = 'Nice sentence.\r\nAlso a nice sentence.';
$destination = str_replace(array('\r', '\n'), array("\r", "\n"), $source);
Sean Bright
  • 118,630
  • 17
  • 138
  • 146