title: Parsing a mix of structured and unstructured text
body: <p>I need to parse blocks of text which are in a format something like this:</p>
  
  <pre><code>Today the weather is excellent bla bla bla.
  &lt;temperature&gt;35&lt;/temperature&gt;. 
  I'm in a great mood today. 
  &lt;item&gt;Desk&lt;/item&gt;
  </code></pre>
  
  <p>I want to parse text like this, and translate it into an array which resembles something like this:</p>
  
  <pre><code>$array[0]['text'] = 'Today the weather is excellent bla bla bla. ';
  $array[0]['type'] = 'normalText';
  
  $array[1]['text'] = '35';
  $array[1]['type'] = 'temperature';
  
  $array[2]['text'] = ". I'm in a great mood today.";
  $array[2]['type'] = 'normalText';
  
  $array[3]['text'] = 'Desk';
  $array[3]['type'] = 'item';
  </code></pre>
  
  <p>Essentially, I want the array to contain all of the text in the same order as in the original text, but split into types: Normal text (meaning stuff which wasn't between any tags), and other types like temperature, item, which were determined by the tags the text was between.</p>
  
  <p>Is there a way to do this (i.e seperate the text into normal text, and other types, using regular expressions) or should I behind the scenes convert the text into properly structured text, like:</p>
  
  <pre><code>&lt;normal&gt;Today the weather is excellent bla bla bla.&lt;/normal&gt;
  &lt;temperature&gt;35&lt;/temperature&gt;.
  &lt;normal&gt; I'm in a great mood today.&lt;/normal&gt;&lt;item&gt;Desk&lt;/item&gt;
  </code></pre>
  
  <p>Before it tries to parse the text?</p>