Re: Extra blank lines bomb fgetcsv function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <20031202005217.76315.qmail@xxxxxxxxxxxxxxxxxxxxxxx>, 
karenresplendo@xxxxxxxxx says...
> Here is the beginning of a big loop that loads a line at a time from an uploaded textfile and then runs validation on each field:
>  
> ////////////////////////////////////////////////////////////////////////
> //loop through the rows putting the fields into an array
> ////////////////////////////////////////////////////////////////////////
> while ($fieldarray = fgetcsv ($handle, $userfile_size, ",")) {
>  
>  
> The problem I am having is that when there is an empty line at the bottom of the txt file, my validation tells me it is a bad line, and rejects the file. Is there anyway of stopping the loop, or trimming the file of empty lines? Hope I've explained my problem correctly.

According to the docs, "A blank line in a CSV file will be returned as an 
array comprising a single null field, and will not be treated as an 
error." So I imagine you need to apply your validation only where the 
array != a single null field.

Cheers
-- 
Quod subigo farinam

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux