preg_match_all loop match
<pre><code>&lt;?php
$arr = array();
$html = "&lt;p class='images'&gt;
&lt;img src='URL1'&gt;
&lt;img src='URL2'&gt;
&lt;img src='URL3'&gt;
&lt;img src='URL4'&gt;

&lt;/p&gt;

&lt;p&gt;&lt;img src='ThisNot'&gt;&lt;/p&gt;
";
preg_match_all('/&lt;p class=\'images\'&gt;(?:\s*&lt;img src=\'([^\']*)\'&gt;\s*)*\s*&lt;\/p&gt;/ism', $html,$arr);


print_r($arr);
</code></pre>

<p>OUTPUT</p>

<pre><code>Array (
    [0] =&gt; Array
        (
            [0] =&gt; &lt;p class='images'&gt; &lt;img src='URL1'&gt; &lt;img src='URL2'&gt; &lt;img src='URL3'&gt; &lt;img src='URL4'&gt;

&lt;/p&gt;
        )

    [1] =&gt; Array
        (
            [0] =&gt; URL4
        )

)
</code></pre>

<p>The regex * only returns the last match in preg_match_all The match has occurred but has not returned to the output array How can I get all the URLs?</p>

<p>It worked when I tried to use two preg_match_all the first to get <p> content and then match with all the images but I would like to get with just one</p>