PHP - dividir uma string de atributos HTML em uma matriz indexada

Eu tenho uma string com atributos HTML:

$attribs = ' id= "header " class = "foo   bar" style ="background-color:#fff; color: red; "';

Como transformar essa string em uma matriz indexada, como:

array(
  'id' => 'header',
  'class' => array('foo', 'bar'),
  'style' => array(
    'background-color' => '#fff',
    'color' => 'red'
  )
)

então eu posso usar a função PHP array_merge_recursive para mesclar 2 conjuntos de atributos HTML.

Obrigado

questionAnswers(5)

yourAnswerToTheQuestion