Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined offset 1

Tags:

I am facing a problem that undefined offset :1 in line 3. I can't understand that what type of error it is. Can anyone tell me that why such error occurs in php

Undefined offset in line : 3

    foreach ($lines as $line)     {       list($var,$value) = explode('=', $line); //line 3       $data[$var] = $value;     } 
like image 223
tushAR Avatar asked May 24 '13 05:05

tushAR


1 Answers

Your are getting PHP notice because you are trying to access an array index which is not set.

list($var,$value) = explode('=', $line); 

The above line explodes the string $line with = and assign 0th value in $var and 1st value in $value. The issue arises when $line contains some string without =.

like image 131
Nauphal Avatar answered Oct 14 '22 20:10

Nauphal