March 10, 2012
Convert dot syntax like "this.that.other" to multi-dimensional array in PHP
Question by Bryan Potts
Just as the title implies, I am trying to create a parser and trying to find the optimal solution to convert something from dot namespace into a multidimensional array such that
s1.t1.column.1 = size:33%
would be the same as
$source['s1']['t1']['column']['1'] = 'size:33%';
Answer by Starx
Although pasrse_ini_file() can also bring out multidimensional array, I will present a different solution. Zend_Config_Ini()
$conf = new Zend_COnfig_Ini("path/to/file.ini");
echo $conf -> one -> two -> three; // This is how easy it is to do so
//prints one.two.three