fork download
  1. <?php
  2.  
  3. $input = '{a{b{c{d}}}}';
  4. preg_match_all('/(?:^(?=({\w+(?1)?})$)|\G(?!\A)){(\w+)/', $input, $matches);
  5. print_r($matches[2]);
Success #stdin #stdout 0.01s 82944KB
stdin
Standard input is empty
stdout
Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
)