What is the best way to detect if a file has Unix style line endings (\r\n
) programatically in PHP and if file has Unix line endings convert the file to Windows style line endings (\n
)?
Asked
Active
Viewed 942 times
0

Enamul Hassan
- 5,266
- 23
- 39
- 56

devnull
- 221
- 1
- 3
- 7
-
3Possible duplicate of [Windows command to convert Unix line endings?](http://stackoverflow.com/questions/17579553/windows-command-to-convert-unix-line-endings) – chris85 Aug 04 '16 at 00:18
-
Look this: http://stackoverflow.com/questions/11066857/detect-eol-type-using-php – SyncroIT Aug 04 '16 at 00:18
-
You have those back to front; it's Windows with `\r\n`. – Walf Aug 04 '16 at 01:20
-
how far had you tried? – Enamul Hassan Aug 06 '16 at 02:51
-
2Actually, it's LF for Unix, CR for Macintosh and CRLF for MS Windows. – Joe DF Aug 06 '16 at 03:50