length argument in fgetcsv

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

length argument in fgetcsv

Post by anjanesh »

From PHP Manual fgetcsv(),
length (Optional)

Must be greater than the longest line (in characters) to be found in the CSV file (allowing for trailing line-end characters). It became optional in PHP 5. Omitting this parameter (or setting it to 0 in PHP 5.0.4 and later) the maximum line length is not limited, which is slightly slower.
I ran the exact code which has the line while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
My CSV file has some lines greater than 1000 characters. It still read the fields.
What exactly is the length argument ?

Thanks
Last edited by anjanesh on Thu Jan 05, 2006 7:48 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you running PHP 5 or greater?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Running PHP 5.0.3 but its mentioned - or setting it to 0 in PHP 5.0.4 and later
Post Reply