This must be simple somehow but I can't figure it out and have been at it for the whole day already.
I want to parse a CSS file into an array with keys and values like this:
Array('#idname' => Array('overflow' => hidden, 'color' => '#FFF'));
I ignore all media queries by removing them with a regular expression and also remove all whitespace.
//Remove all media queries
$cssFromLink = preg_replace("/@media.*?}}/i", '', $cssFromLink);
//Remove all whitespace
$cssFromLink = str_replace(' ','', $cssFromLink);
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.
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.
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.