[eluser]Christopher Blankenship[/eluser]
And here would be away to fix the code so it would work.
Code:
<?php
$myfile = 'globals.php';
$file_handle = fopen($myfile, 'r');
while (!feof($file_handle)) {
$line = fgets($file_handle);
$parts = split("=", $line);
if (isset($parts[0]) && isset($parts[1])) {
$key = trim(str_replace('$GLOBALS[\'', "", $parts[0]));
$key = trim(str_replace('\']', "", $key));
$value = trim(str_replace(array('"', "'", ";","]"), "", $parts[1]));
$config[$key] = $value;
}
}
fclose($file_handle);
print_r($config);
?>
globals.php
Code:
<?php
$GLOBALS['dbname'] = 'test';
$GLOBALS['dbuser'] = 'test1';
$GLOBALS['dbpass'] = 'test2';
?>
This would output the following:
Array ( [dbname] => test [dbuser] => test1 [dbpass] => test2 )