Home > other >  Reading CSV file with PHP and display the data in HTML/PHP
Reading CSV file with PHP and display the data in HTML/PHP

Time:09-05

I'm trying to create and read some csv files and display them using html but it's giving me some errors :/ , I followed a tutorial on youtube but it still gives me an error and I don't understand why

I used 3 columns in excel and i put some text but when I go to test it, it puts it in just one column

Undefined array error

i tried to use var_dump function to check $data to see what i was getting through fgetcsv and i get this: "bool(false)"

I noticed that when saving an excel file, 3 or 4 options appear to save as csv

I chose "CSV(separated by commas)", i don't know if this could be the problem

this is the code i have: Code1,Code2

Excel

CodePudding user response:

It is because your delimiter in the file is a semi-colon. But the delimiter set in "fgetcsv" is a comma.

You have to change that to a semi-colon.

Like this:

while (($data = fgetcsv($handle, 1000, ";")) !== FALSE)
  • Related