Last active
October 13, 2015 15:37
-
-
Save giovanniramos/4217717 to your computer and use it in GitHub Desktop.
Interprets an INI file with heritage section
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Interprets an INI file with heritage section | |
* | |
* @param string $filename Filename | |
* @return array | |
* @link https://gist.github.com/4217717 | |
* | |
*/ | |
function parse_ini_file_advanced($filename) | |
{ | |
$nArr = array(); | |
$oArr = parse_ini_file($filename, true); | |
if (is_array($oArr)) { | |
foreach ($oArr as $k => $v) { | |
$k = preg_split('~[:]~', preg_replace('~[\s]{1,}~', null, $k)); | |
$t = &$nArr; | |
foreach ($k as $x) { | |
$t = &$t[$x]; | |
} | |
$t = $v; | |
} | |
} | |
return $nArr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment