Because of browser wars and whatnot, a lot of CSS3 components have to be written in many different syntaxes to work.
E.g. -moz-box-shadow and -webkit-box-shadow (even though they're identical in format)
So, my solution is to write simple flags in the CSS file which a PHP script will replace for the correct CSS needed. I've got the browser detection and php re-writing all working, but - in my regex noobery - I just cant find a way to extract the flags and replace them.
Some sample code would be:
The particular format of my 'generic code' isn't important: I just chose this as it seems easy to decode.
Where (if we were using Firefox) the script would replace that with:
background: -moz-linear-gradient(top, #FFFFFF 0%, #E5E5E5 100%);
Now I've made a Regex function which works perfectly well at selecting this example of text:
But how do I use that to obtain the generic code, pass it to the re-writing function depending on the browser, and replace the generic code with browser-specific code?
I found preg_replace_callback.
All I need to do is:
$linGrads = preg_replace_callback('/LINEAR-GRADIENT:\[.+?\]/', 'editingFunction', $input);