Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an array be specified in an ini file to be parsed using Zend_Config_Ini

Is there a way to specify a one dimensional array in a ini file.

so in my ini I would like to do

someproperty = [array of something]

I am using Zend_Config_Ini config adapter (I prefer ini for base configuration).

like image 454
Akeem Avatar asked Dec 03 '08 20:12

Akeem


2 Answers

You can use separators to make further sub-sections, and they are presented as either another level of objects ($config->some->a) or with $config->toArray(), they can be turned into a multi-level array.

Combining both the above techniques to make arrays, and the separators like so:

some.a[] = a
some.a[] = b
some.b[] = c

will give the results you are looking for.

array('some' => array('a' => array(0 => 'a',
                                   1 => 'b'),
                      'b' => array(0 => 'c')
                     ));
like image 66
Alister Bulman Avatar answered Oct 29 '22 06:10

Alister Bulman


Although undocumented, this seems to work quite well too:

foo[bar] = 5
foo[baz] = 6
hello[world] = 7
like image 20
maček Avatar answered Oct 29 '22 05:10

maček