title: PHP CSS from string to array
body: <p>This must be simple somehow but I can't figure it out and have been at it for the whole day already. </p>
  
  <p>I want to parse a CSS file into an array with keys and values like this:</p>
  
  <pre><code>Array('#idname' =&gt; Array('overflow' =&gt; hidden, 'color' =&gt; '#FFF'));
  </code></pre>
  
  <p>I ignore all media queries by removing them with a regular expression and also remove all whitespace.</p>
  
  <pre><code>//Remove all media queries
  $cssFromLink = preg_replace("/@media.*?}}/i", '', $cssFromLink);
  //Remove all whitespace
  $cssFromLink = str_replace(' ','', $cssFromLink);
  </code></pre>
  
  <p>All that I want is to be able to search in a list for an id or classname and then extract a property like background-color.</p>
  
  <p>Libraries like Sabberworm and other CSS parsers don't seem to work for me, they either seem to be taking forever/do nothing or throw a fatal error. I am trying this on the css from apple.com.</p>
  
  <p>All others solutions look equally complex to me but almost none of them seem to work for apple.com specifically and I can't have it crash on popular websites.</p>