Re: fgetcsv doesn't return an array?

From: Date: Thu, 15 Mar 2012 17:54:41 +0000
Subject: Re: fgetcsv doesn't return an array?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-317032@lists.php.net to get a copy of this message
Jay Blanchard wrote:
154     $csvCurrentLine = fgetcsv($csvFile, 4096, ',');
155     $currentLine = implode(",", $csvCurrentLine);
I am using it in a loop. End Of File is an error?
You certainly need to break out on $csvCurrentLine = false which indicates end of file at least. My own 'loop' is $row=0; while (($data = fgetcsv($handle, 800, ",")) !== FALSE) { if ( $row ) $contact->RecordLoad( $data, $row );
    	$row++;
} The row bit strips the header line from the csv file ... -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php

« previous php.general (#317032) next »