I have text like this between brackets [ and ]:
$commands = "[CMD1,[CMD2],[CMD3,[CMD4],[CMD5]]]";
and execute with this PHP function:
preg_match_all('/\\[(.*?)\\]/', $commands, $matches);
And output of index 1 is:
array(2) (
...
1 => array(3) (
0 => string(10) "CMD1,[CMD2"
1 => string(10) "CMD3,[CMD4"
2 => string(4) "CMD5"
)
)
however I want to process the deepest one first, output like this:
array(2) (
...
1 => array(3) (
0 => string(4) "CMD5"
1 => string(4) "CMD4"
2 => string(4) "CMD3"
3 => string(4) "CMD2"
4 => string(4) "CMD1"
)
)
Can preg_match_all do that?