title: preg_replace all img tags with something else
body: <p>so basically what i need to do is replace all   </p>
  
  <pre><code>&lt;img src="random image goes here" class="random class goes here" alt="random alt goes here" /&gt;
  </code></pre>
  
  <p>with  </p>
  
  <pre><code>&lt;table&gt;
      &lt;a href="#"&gt;src="random image goes here" class="random class goes here" alt="random alt goes here" /&gt;&lt;/a&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>in a content. I tried to do it with preg_replace, but without success, maybe you could try helping me?</p>
  
  <p>Here is what I've tried -</p>
  
  <pre><code>$content = preg_replace('/"&gt;&lt;img class=/', '"&gt;&lt;table class="image-caption aligncenter"&gt;&lt;tr&gt;&lt;td&gt;&lt;div&gt;&lt;a href="#" target="blank"&gt;&lt;img class=', $content);
  $content = preg_replace('/ \&gt;&lt;\a&gt;/i', ' /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/a&gt;', $content);
  </code></pre>