title: Using preg_split for templating engine
body: <p>I am building a templating engine and would like to allow nested logic. </p>
  
  <p>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].</p>
  
  <p>Here is the input string:</p>
  
  <pre><code>@if(param1&gt;=7) [ something here @if(param1&gt;9)[ nested statement ] ] @elseif(param2==true) [ 2st condition true ] @else [ default condition ] 
  </code></pre>
  
  <p>The result should look like:</p>
  
  <pre><code>array(
  
     " if(param1&gt;=7) [ something here @if(param1&gt;9)[ nested statement ] ] ",
  
     " elseif(param2==true) [ 2st condition true ] ",
  
     " else [ default condition ] "
  
  )
  </code></pre>
  
  <p>I believe preg_split is what Im looking for but could use help with the regex </p>