title: preg_match_all returns only last matches from single row , but all matches from multi row string
body: <p>I try to find all occurrences of sub-string in text, using <code>preg_match_all</code> function:</p>
  <pre><code>&lt;?php
  
  $str = '&lt;p&gt;this &lt;a href=&quot;https://api.slack.com/apps/&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt; and &lt;a href=&quot;https://www.google.com&quot; target=&quot;_blank&quot;&gt;link 2&lt;/a&gt;&lt;/p&gt;';
  
  
  
  $reg = '/&lt;a.*href=&quot;([^&quot;]+)&quot;[^&gt;]+&gt;(.+)&lt;\/a&gt;/';
  
  preg_match_all($reg, $str, $m);
  
  print_r($m);
  </code></pre>
  <p>but above code returns only last link: <a href="https://phpize.online/sql/mysql57/undefined/php/php81/77da0b585127809df1880d06d224716c/" rel="nofollow noreferrer">run php online</a></p>
  <p>When I split source text into rows, same code return all matches:</p>
  <pre><code>&lt;?php
  
  $str = '&lt;p&gt;this &lt;a href=&quot;https://api.slack.com/apps/&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt; and 
  the &lt;a href=&quot;https://www.google.com&quot; target=&quot;_blank&quot;&gt;link 2&lt;/a&gt;&lt;/p&gt;';
  
  
  
  $reg = '/&lt;a.*href=&quot;([^&quot;]+)&quot;[^&gt;]+&gt;(.+)&lt;\/a&gt;/';
  
  preg_match_all($reg, $str, $m);
  
  print_r($m);
  </code></pre>
  <p><a href="https://phpize.online/sql/mysql57/undefined/php/php81/269cb5b03948d8450be6de3c5975f9ba/" rel="nofollow noreferrer">php sandbox here</a></p>