I have the next INI file:
a.b.c = 1
a.b.d.e = 2
I am parsing this file using parse_ini_file. And it returns:
array(
'a.b.c' => 1,
'a.b.d.e' => 2
)
But I want to create a multidimensional array. My outout should be:
array(
'a' => array(
'b' => array(
'c' => 1,
'd' => array(
'e' => 2
)
)
)
)
Thank you in advance.
This is how I see it:
Have a look at the Zend_Config_Ini class. It does what you want, you can use it standalone (without the rest of Zend Framework) and as a bonus it supports section inheritance.
With the
toArray
method you can create an array from the config object.Take a look at PHProp.
Similar to
Zend_Config_Ini
, but you can refer to a key in your config like${key}
It's actually quite simple, you only need to change the format of the array you already have by exploding it's key:
Output:
See as well: String with array structure to Array.
It's a my class for parsing config ini files to a multidimensional array: