How to save the output of php variables used in inline css code to the main style.css?

The PHP Manual, specifically file_put_contents will point you in the right direction. My suggestion is to write the name/value pairs to an array, insert a comment at the top of a blank CSS file and add an import directive to the master style sheet until you test the output, then dump the array into the test stylesheet.