Skip to content
Advertisement

Tag: fgetcsv

PHP – fgetcsv loop for get data from csv file column by column

I have a CSV file with 31 columns and 24 rows. I need with fgetcsv (or maybe another solution) to pass in the CSV and get data column by column. I have one solution: The for loop is working but $data[$col] only gets data from the first column of the CSV, it doesn’t get data from $data[$col] when $col is

php://memory IO stream and fgetcsv()

I want to parse csv-like string so I can emulate csv and assert it into a test case. But it won’t parse into arrays. This is the output: Answer Remove the rn, not needed Your moving the pointer twice per loop, change to $parsed[] = $data

Finding duplicate column values in a CSV

I’m importing a CSV that has 3 columns, one of these columns could have duplicate records. I have 2 things to check: So far, I’m parsing the CSV file, once and checking that 1. (NAME is valid), which if it fails, it simply breaks out of the while loop and stops. I guess the question is, how I’d check that

Advertisement