PHP Notice: Undefined offset: 1 with array when reading data

前端 未结 10 1513
遇见更好的自我
遇见更好的自我 2020-12-04 15:14

I am getting this PHP error:

PHP Notice:  Undefined offset: 1

Here is the PHP code that throws it:

$file_handle = fopen($pa         


        
10条回答
  •  不思量自难忘°
    2020-12-04 15:34

    my quickest solution was to minus 1 to the length of the array as

      $len = count($data);
    
        for($i=1; $i<=$len-1;$i++){
          echo $data[$i];
        }
    

    my offset was always the last value if the count was 140 then it will say offset 140 but after using the minus 1 everything was fine

提交回复
热议问题