I'm generating a dynamic CSS using PHP. I've got individual values looking like:
$padding_top = 10;
$padding_bottom = 10;
$padding_left = 10;
$padding_right = 10;
Now, I would like to generate CSS shorthand for all css rules where shorthand notation is possible. So the above example should turn into:
padding: 10px;
I'm sure there must already be a library for this, but I couldn't find it, and before I start writing a hairy heap of conditional statements, I thought I'd give it a go here first.. Any suggestions as to how to most elegantly achieve this?
Update as per comments,
maybe worthwhile taking a look at CSSTidy and building something on that
CSSTidy is an opensource CSS parser and optimiser. It is available as executeable file (available for Windows, Linux and OSX) which can be controlled per command line and as PHP script (both with almost the same functionality). In opposite to most other CSS parsers, no regular expressions are used and thus CSSTidy has full CSS2 support and a higher reliability.
have you tried LESSPHP
not sure it'll do exactly what you're asking but you should be able to build your own mixins to suit