20

So for example I could do like this with it :

$css = new simple_css();
foreach ($css->find_elements_with_property('margin') as $element) {
  //do my stuff
  if ($something) {
    $elem->spacing = '1px';
  }
}
$processed_css = $css->plaintext();
1
  • 3
    Something like that would certainly be useful Commented Nov 16, 2011 at 10:02

5 Answers 5

6
+50

I searched phpclasses.org:

 <?php
include("cssparser.php");

$css = new cssparser();
$css->ParseStr("b {font-weight: bold; color: #777777;} b.test{text-decoration: underline;}");
echo $css->Get("b","color");     // returns #777777
echo $css->Get("b.test","color");// returns #777777
echo $css->Get(".test","color"); // returns an empty string
?> 

Link: http://www.phpclasses.org/package/1289-PHP-CSS-parser-class.html

Sign up to request clarification or add additional context in comments.

Comments

2

I'm only aware of two projects:

I haven't really used any of them.

Comments

2

Not sure if this is of any use? sabberworm... available on github https://github.com/sabberworm/PHP-CSS-Parser, havent used it myself but a college has and mentioned it was useful...

1 Comment

I use this tool its impressive.
1

Probably , You can use HtmlUnit

Comments

1

It's not the same but with LESS (that is the only stable project that I know on the subject) you van achieve the same by using mixins with guards.

Take a look http://lesscss.org/#docs

Hope this helps

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.