title: PHP Regular Expression that returns array of matches (preg_match vs preg_match_all)
body: <p>I am trying to get an array of all the successful matches of my Regex and in this case an array of all the Data URIs so as to iterate through the array and convert each Data URI to a file.</p>
  
  <pre><code>&lt;?php
  $string = '&lt;img src="data:image/png;base64,FAKEIMAGE0XXXXXAKJDBFLASDGFSDGAFJLSD==" alt="Fake img 0" /&gt;&lt;img src="data:image/png;base64,FAKEIMAGE1XXXXXAKJDBFLASDGFSDGAFJLSD==" alt="Fake img 1" /&gt;&lt;img src="data:image/png;base64,FAKEIMAGE2XXXXXXXAKJDBFLASDGFSDGAFJLSD==" alt="Fake img 2" /&gt;&lt;img src="data:image/png;base64,FAKEIMAGE3XXXXXXAKJDBFLASDGFSDGAFJLSD==" alt="Fake img 3" /&gt;';
  $pattern = '@src="([^"]+)"@';
  echo preg_match($pattern, $string, $matches, PREG_OFFSET_CAPTURE);
  var_dump($matches);
  </code></pre>
  
  <p>I would like a result like below:</p>
  
  <pre><code> Array(4) { [0]=&gt; string(60) "data:image/png;base64,FAKEIMAGE0XXXXXAKJDBFLASDGFSDGAFJLSD==" [1]=&gt; string(60) "data:image/png;base64,FAKEIMAGE1XXXXXAKJDBFLASDGFSDGAFJLSD==" [2]=&gt; string(62) "data:image/png;base64,FAKEIMAGE2XXXXXXXAKJDBFLASDGFSDGAFJLSD==" [3]=&gt; string(61) "data:image/png;base64,FAKEIMAGE3XXXXXXAKJDBFLASDGFSDGAFJLSD==" }
  </code></pre>