I want to convert nested brackets to array with keywords. Here is pattern:
preg_match_all('/(?=\{((?:[^{}]++|\{(?0)\})++)\})/', $string, $res);
And data which need to parse:
employee {
cashier { salary = 100; }
technician { age = 44; }
}
Result, that I need:
Array
(
[employee] => Array (
[0] => Array
(
[cashier] => Array
(
[salary] => 100
)
)
[1] => Array
(
[technician] => Array
(
[age] => 44
)
)
)
)
But cant iterate within nested brackets. Stucked here. Thanks in advance for your help
preg_splitmight be more suitable