title: php find all elements with style attribute using preg_match_all
body: <p>I just want to find ALL elements with preg_match_all in a html document. After reading the file i am using the following:</p>
  
  <pre><code>preg_match_all('&lt;.*style=?.*&gt;',$file,$patterns);
  print_r( $patterns[0] ); die;
  </code></pre>
  
  <p>Gives all the elements but with spacing and other stuff before the &lt; and >. Also the output has an end tag in the result (for example: '). I have play around with preg expressions but drives me insane. Can somebody tell me what is the correct syntax to use?</p>
  
  <p>The output is now:</p>
  
  <pre><code>Array
  (
      [0] =&gt; &lt;table style="position:absolute;width:100%;height:100%;"&gt;
      [1] =&gt;  &lt;div class="_barcode_pdf417" style="margin:0 auto;width:176px;height:132px;background:#FFF;color:#000;"&gt;&lt;div style="margin:0 auto;margin:0;padding:0;border:0"&gt;
      [2] =&gt;      &lt;div style="position:absolute;width:14px;height:128px;background:#000;"&gt;&lt;/div&gt;
      [3] =&gt;      &lt;div style="position:absolute;margin-left:18px;width:2px;height:128px;background:#000;"&gt;&lt;/div&gt;
      [4] =&gt;      &lt;div style="position:absolute;margin-left:22px;width:2px;height:128px;background:#000;"&gt;&lt;/div&gt;
      [5] =&gt;      &lt;div style="position:absolute;margin-left:26px;width:2px;height:128px;background:#000;"&gt;&lt;/div&gt;
  ........
  ........
  ........
  </code></pre>
  
  <p>But i want:</p>
  
  <pre><code>Array
  (
      [0] =&gt; &lt;table style="position:absolute;width:100%;height:100%;"&gt;
      [1] =&gt; &lt;div class="_barcode_pdf417" style="margin:0 auto;width:176px;height:132px;background:#FFF;color:#000;"&gt;
  &lt;div style="margin:0 auto;margin:0;padding:0;border:0"&gt;
      [2] =&gt; &lt;div style="position:absolute;width:14px;height:128px;background:#000;"&gt;
      [3] =&gt; &lt;div style="position:absolute;margin-left:18px;width:2px;height:128px;background:#000;"&gt;
      [4] =&gt; &lt;div style="position:absolute;margin-left:22px;width:2px;height:128px;background:#000;"&gt;
      [5] =&gt; &lt;div style="position:absolute;margin-left:26px;width:2px;height:128px;background:#000;"&gt;
  ......
  ......
  </code></pre>
  
  <p>Thank you for your answer! Kind regards.</p>