title: PHP split string by <img> and break output
body: <p>I am have some HTML content, and I need to parse it, get all the images. Then print out the whole content but running a PHP class instance in every occurrence of the image</p>
  
  <pre><code>This is the content
  
  &lt;?php $content = 'Some text
  &lt;p&gt;A paragraph&lt;/p&gt;
  &lt;img src="image1.jpg" width="200" height="200"&gt;
  More text
  &lt;img src="image2.jpg" width="200" height="200"&gt;'; ?&gt;
  </code></pre>
  
  <p>I need to be able to get the images and run a class method with the output.</p>
  
  <p>So the result would be something like</p>
  
  <pre><code>&lt;?php echo 'Some text
  &lt;p&gt;A paragraph&lt;/p&gt;';
  
  $this-&gt;Image('image1.jpg', PDF_MARGIN_LEFT, $y_offset, 116, 85);
  echo 'More text';
  $this-&gt;Image('image2.jpg', PDF_MARGIN_LEFT, $y_offset, 116, 85);
  </code></pre>
  
  <p>But obviouly I imagine it would have to be a loop or something that does it automatically</p>