Code works in php 5 but not php 7, returning single element of array from class function

This was working but now on php7, recent install, returns
"Array ( [host] => 127.0.0.1 [username] => root [password] => [db] => scaryminds ) 127.0.0.1 "
Am after 127.0.0.1 btw.
Relavent code
public static function get($path = null) {
if($path) {
$config = $GLOBALS['config'];
$path = explode('/', $path);
foreach($path as $bit) {
if(isset($config[$bit])) {
$config = $config[$bit];
}
print_r($config);
//return $config;
}
}
}
Calling routine line
echo Config::get('mysql/host'); // 127.0.0.1
MySQL details stored in an array from an include file
$GLOBALS['config'] = array(
'mysql' => array(
'host' => '127.0.0.1',
'username' => 'root',
'password' => '',
'db' => 'scaryminds'
),
So I guess the question is why the line $config = $config[$bit] is returning the entire array with the additional $bit appended rather than just returning $bit.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to undefined function mysqli_connect()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.