![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2006
Posts: 40
Rep Power: 0
![]() |
New line problem
How can I avoid a full blank line while reading information from a text file.
Im going to parse this text and insert the information into a database however there are some blank lines and these get me in trouble because Im parsing the text using explode and Im parsing it according to the \r\n at first.So it gets the blank lines as well.But It mustnt get. anyone helps?? |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Just preprocess the text to change all instances of \r\n\r\n to \r\n.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Why not just check the line length as you go along?
[php]if (strlen($line) > 0) { // do stuff } else { // ignore }[/php] |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2006
Posts: 40
Rep Power: 0
![]() |
Thanx.I have found a different solution.I made the check before inserting into the database...Its something like u said Ooble.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|