I am a newbie and have written some code in PHP which gives me above mentioned notice. My program works perfectly but i want to resolve the notice. I know i can turn off the notice, but i dont want to do that. Please let me know how can i fix it.
My code -
$GLOBALS['config'] = array(
'mysql' => array(
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => 'app'
)
);
$config = $GLOBALS['config'];
$path = explode('/', 'mysql/host');
foreach($path as $bit){
if(isset($config[$bit])){
$config = $config[$bit];
}
}
echo $config;
My output from
echo $config;
is 127.0.0.1 and it is as expected.
But i am getting the notice on line -
$config = $GLOBALS['config'];
Please help.