title: PHP split or explode string on <img> tag
body: <p>i would like to split a string on a  tag into different parts. </p>
  
  <pre><code>$string = 'Text &lt;img src="hello.png" /&gt; other text.';
  </code></pre>
  
  <p>The next function doesnt work yet on the right way.</p>
  
  <pre><code>$array = preg_split('/&lt;img .*&gt;/i', $string);
  </code></pre>
  
  <p>The output should be </p>
  
  <pre><code>array(
      0 =&gt; 'Text ',
      1 =&gt; '&lt;img src="hello.png" /&gt;',
      3 =&gt; ' other text.'
  )
  </code></pre>
  
  <p>What kind of pattern should i use to get it done?</p>
  
  <p><strong>EDIT</strong>
  What if there are multiple  tags?</p>
  
  <pre><code>$string = 'Text &lt;img src="hello.png" &gt; hello &lt;img src="bye.png" /&gt; other text.';
  $array = preg_split('/(&lt;img .*&gt;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
  </code></pre>
  
  <p>And the output should be:</p>
  
  <pre><code>array (
    0 =&gt; 'Text ',
    1 =&gt; '&lt;img src="hello.png" /&gt;',
    3 =&gt; 'hello ',
    4 =&gt; '&lt;img src="bye.png" /&gt;',
    5 =&gt; ' other text.'
  )
  </code></pre>