eevan79 Posted August 19, 2010 Share Posted August 19, 2010 When I enable error_reporting this notice appear: Notice: Undefined offset: 1 This is code: function get_value_of($name) { $lines = file("../config.php"); $val = array(); foreach (array_values($lines) AS $line) { list($key, $val) = explode('=', trim($line) ); if (trim($key) == $name) { $val = convEnt($val); return $val; } } return false; } Error is in this line: list($key, $val) = explode('=', trim($line) ); How to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/211198-undefined-offset/ Share on other sites More sharing options...
mikosiko Posted August 19, 2010 Share Posted August 19, 2010 Most likely one of your lines doesn't contain a '=' Quote Link to comment https://forums.phpfreaks.com/topic/211198-undefined-offset/#findComment-1101311 Share on other sites More sharing options...
eevan79 Posted August 20, 2010 Author Share Posted August 20, 2010 You are right. I fixed it: if (strstr($line,"=")) { ... Quote Link to comment https://forums.phpfreaks.com/topic/211198-undefined-offset/#findComment-1101477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.