I am building a templating engine and would like to allow nested logic.
I need to split the following string using "@" for the delimiter but would like to ignore this delimiter - treat is as just another character - if its inside the [square brackets].
Here is the input string:
@if(param1>=7) [ something here @if(param1>9)[ nested statement ] ] @elseif(param2==true) [ 2st condition true ] @else [ default condition ]
The result should look like:
array(
" if(param1>=7) [ something here @if(param1>9)[ nested statement ] ] ",
" elseif(param2==true) [ 2st condition true ] ",
" else [ default condition ] "
)
I believe preg_split is what Im looking for but could use help with the regex