title: PHP - split a string of HTML attributes into an indexed array
body: <p>I've got a string with HTML attributes:</p>
  
  <pre><code>$attribs = ' id= "header " class = "foo   bar" style ="background-color:#fff; color: red; "';
  </code></pre>
  
  <p>How to transform that string into an indexed array, like:</p>
  
  <pre><code>array(
    'id' =&gt; 'header',
    'class' =&gt; array('foo', 'bar'),
    'style' =&gt; array(
      'background-color' =&gt; '#fff',
      'color' =&gt; 'red'
    )
  )
  </code></pre>
  
  <p>so I can use the PHP array_merge_recursive function to merge 2 sets of HTML attributes.</p>
  
  <p>Thank you</p>