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; }
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 =
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With