hi, im not such a php expert and i want to parse a csv file located at http://www.totalbeauty.com/resource/lists. does anyone know how i can do this, what to watch out for, the best way to do this and just general tips for parsing files.
thanks..

Recommended Answers

All 4 Replies

http://php.net/fgetcsv There's a builtin PHP function

does anyone know how to get the max lenght of any line in the file? the fgetcsv() requires a lenght argument that should ne greater that the longest line in the file.

does anyone know how to get the max lenght of any line in the file? the fgetcsv() requires a lenght argument that should ne greater that the longest line in the file.

Unless you're using PHP4 you don't need it, if the PHP document shows an argument in [] then it is optional

fgetcsv() parses the line it reads for fields in CSV format and returns an array containing the fields read.
. . . . .
length
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.
. . . . .

no longer really necessary, if your host is running php5

its not a very well formed file, only 3 lines, a list of brandnames, semi-colon separated no quotes

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.