This is an example of a mixed, multi-level, irregular array in php:
$settings['style_formats'] = array(
array('title' => 'Center table', 'selector' => 'table', 'styles' => array('margin-left' => 'auto', 'margin-right' => 'auto')),
array('title' => 'Menu style', 'selector' => 'ul,ol', 'classes' => 'menu'),
array('title' => 'Layer2', 'inline' => 'div', 'styles' => array('background-color' => 'orange')),
array('title' => 'Bold text', 'inline' => 'b'),
array('title' => 'Red text', 'inline' => 'span', 'styles' => array('color' => '#ff0000')),
array('title' => 'Red header', 'block' => 'h1', 'styles' => array('color' => '#ff0000')),
array('title' => 'Example 1', 'inline' => 'span', 'classes' => 'example1'),
array('title' => 'Example 2', 'inline' => 'span', 'classes' => 'example2'),
array('title' => 'Table styles'),
array('title' => 'Table row 1', 'selector' => 'tr', 'classes' => 'tablerow1'),
);
I need to find a method to represent and translate this kind of array from string format to php array. The initial string format must be readable and writeable by a human using a text editor. So e.g. it should not be a result of using "serialize", because "serialize" is a php function (and rather not possible to create by a human) and the string must be possible to create manually in a text editor.
The string will be passed as parameter to a function which will translate it to a php array like the one above.
If it was a simple array, I would use a comma separated string and "explode". But it is multilevel, so using "explode" won't work as it will split internal arrays. preg_split also doesn't look promising because the array is very irregular.
Any ideas how to do it?