title: convert inline styles to css with php
body: <p>I have made a class that can produce allot of different barcode types in several formats like:
  - Any picture format, GIF, JPG, PNG, SVG,etc
  - Compressed javascript (JS)
  - Html with inline styles</p>
  
  <p>The class is already optimized to reduce the output of barcode as small as is possible by 'drawing' only the information that is black.</p>
  
  <p>Because the HTML version of the barcode can be that huge (althought it is already optimized), i wonder if there is a class or function that can convert the inline styles to a style tag, for example:</p>
  
  <p>Output is (just a few lines):</p>
  
  <pre><code>&lt;div id="mybarcode"&gt;
  &lt;div style="position:absolute;margin-left:26px;width:2px;height:128px;background:#000;"&gt;&lt;/div&gt;
  &lt;div style="position:absolute;margin-left:34px;width:2px;height:128px;background:#000;"&gt;&lt;/div&gt;
  &lt;div style="position:absolute;margin-left:36px;width:2px;height:48px;background:#000;"&gt;&lt;/div&gt;
  ......
  ......
  </code></pre>
  
  <p>This is what i want:</p>
  
  <pre><code>&lt;style&gt;
       #mybarcode div {position:absolute;width:2px;height:128px;background:#000;}
      &lt;/style&gt; 
      ....
      ....
  
      &lt;div id="mybarcode"&gt;
      &lt;div style="margin-left:26px;"&gt;&lt;/div&gt;
      &lt;div style="margin-left:34px;"&gt;&lt;/div&gt;
      &lt;div style="margin-left:36px;height:48px;"&gt;
      ....
      ....
  </code></pre>
  
  <p>If found a class that can do the opposite what i want but that is not my case. Does anybody know if there is a class around that can do such things with html? It can also be useful converting other pages with inline styles to html with external css.</p>
  
  <p>Thank you for your answer! kind regards.</p>