PHP fgetcsv count lines end of file, eof

November 17, 2014

Due to fgetcsv read only a line from open file, or line by line if looping. As decribe below, it doesn’t able to return number of line from specific file. The fgetcsv() function parses a line from an open file, checking for CSV fields. The fgetcsv() function stops returning on a new line, at the […]

PHP dealing with commas in CSV data

November 12, 2014

Look carefully the data, there are multiple commas ‘,’ inside the address field. When transform the data to array, the output will be each commas separated in one array value. Example: (wrong way) Don’t attempt to do this with a regular expression. Just use str_getcsv()! The third parameter informs str_getcsv() to look for quote-enclosed fields. […]