title: How to grab value of custom tag and value between tag
body: <p>The idea is to grab values from the following string.</p>
  
  <pre><code>String: Server has [cpu]4[cpu] cores and [ram]16gb[ram]
  </code></pre>
  
  <p>I need to grab the tags value and what is between the tag dynamically: should not matter what is between <code>[*]*[*]</code></p>
  
  <p>Output: Should be an array as follows</p>
  
  <pre><code>Array(
      'cpu' =&gt; 4,
      'ram' =&gt; '16gb'
  )
  </code></pre>
  
  <p>Having a lot of trouble with the regex pattern. Any help would be appreciated.</p>
  
  <p>EDIT: the value between tags or the tags themselves can be anything - Alphanumeric or Numeric.</p>
  
  <p>The sample string is a sample only. Tags can appear unlimited times and the array therefore needs to be populated on the fly - not manually. </p>