PHP: Undefined index even if it exists

后端 未结 6 775
难免孤独
难免孤独 2021-01-18 03:22

It drives me crazy ... I try to parse a csv file and there is a very strange behavior.

Here is the csv

action;id;nom;sites;heures;jours
i;;\"un nom a         


        
6条回答
  •  不知归路
    2021-01-18 03:39

    Sorry I am posting on an old thread, but thought my answer could add to ones already provided here...

    I'm working with a Vagrant guest VM (Ubuntu 16.04) from a Windows 10 host. When I first came across this bug (in my case, seeding a database table using Laravel and a csv file), @ojovirtual's answer immediately made sense, since there can be formatting issues between Windows and Linux.

    @ojovirtual's answer didn't quite work for me, so I ended up doing touch new_csv_file.csv through Bash, and pasting contents from the 'problematic' CSV file (which was originally created on my Windows 10 host) into this newly-created one. This definitely fixed my issues - it would have been good to learn and debug some more, but I just wanted to get my particular task completed.

提交回复
热议问题