title: PHP Trying to capture nested tags in an array from a string
body: <p>Objective: 
  Loop through string of characters and store custom objects in an array preserving the nested nature.</p>
  
  <p>Examples below of string and array structure.</p>
  
  <p>I have tried recursive regex but couldn't find a solution as it wasn't really made for this (from what I have researched).</p>
  
  <p><em>This is similar to a html/xml parser but for custom tags.</em></p>
  
  <pre><code>//Array structure
  $object["number"];
  $object["children"];
  
      for($i = 0; $&lt;$stringTotal; $i++ {
      $char = $string[$i];
  
      if ($char == "[") {
      //start new object
      }
  
      if ($char == "]") {
      //finish current object
      }
      }
  
  Example: 
  String = "[1]
  [2
    [2.a]
    [2.b
      [2.c]
    ]
  ]"
  </code></pre>