Remove new line character from file
As title - how to remove "enter" aka "^n" from file?
|
Re: Remove new line character from file
You mean strip all new-lines or just the final/starting one? What kind of file is it?
|
Re: Remove new line character from file
Hm. Maybe differently. How to permanently remove line from file ?
PHP Code:
|
Re: Remove new line character from file
Well, afaik, there are two ways.
1. Read lines from file 1 and write them to file 2, skip the deleted lines. 2. Read file 1 into a buffer, remove lines, write to file 2. If you need code, I can show you. Usually, I just do write_file("file", "", line). It's shorter code and I don't really care about extra empty lines. |
Re: Remove new line character from file
As long as the file isn't huge and you are concerned with only removing the carriage returns and not any other data.
1. Read entire file into a buffer 2. Replace all carriage returns with "" 3. Delete original file, create new file |
Re: Remove new line character from file
I think stupok's way would be best.
Code:
That will make the line blank, and shouldn't be a problem when you need to read data. Just make a "if( !data[0] ) continue;" type check. |
Re: Remove new line character from file
Right, for removing an entire line. He originally just requested how to remove the carriage return (not the data following it), which is not what stupoks methods suggests.
|
Re: Remove new line character from file
I'm not quite sure what he's asking for.
Does he want to delete an entire line, or the new line character from the end of the line, causing 2 lines to combine? |
Re: Remove new line character from file
Quote:
|
Re: Remove new line character from file
Quote:
|
| All times are GMT -4. The time now is 02:25. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.