PHP: Undefined index even if it exists

后端 未结 6 777
难免孤独
难免孤独 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:35

    I struggled with this issue until I realised that my chunk of code has been run twice.

    First run when index was present and my array was printed out properly, and the second run when index was not present and the notice error is triggered. That left me wondering "why my obviously existing and properly printed out array is triggering an 'Undefined index' notice". :)

    Maybe this will help somebody.

提交回复
热议问题