title: PHP regexp - how to extract all occurances of a pattern
body: <p>I have a string that contains multiple WIKI-type tags.  e.g. <code>[[TAG:4567]]</code>.  I need to identify/extract all tags from the string so I can perform substitution later.</p>
  
  <p>For example, for this string:</p>
  
  <pre><code>this is a test [[TITLE]] of more test [[LINK:27654]]
  </code></pre>
  
  <p>I want an array of:</p>
  
  <pre><code>0: [[TITLE]]
  1: [[LINK:27654]]
  </code></pre>
  
  <p>I thought that PHP preg_match might work, but it returns a whole bunch of extra character between the regexp matches.  But I think it only works with one match in the subject string.  This is what I tried:</p>
  
  <pre><code>$subject = "this is a test [[TITLE]] of more test [[LINK:27654]]";
  preg_match( '/(?&lt;=\[\[)(.*)(?=\]\])/', $subject, $matches );
  print_r($matches);
  </code></pre>
  
  <p>But it gives me:</p>
  
  <pre><code>Array ( 
      [0] =&gt; TITLE]] of more test [[LINK:27654 
      [1] =&gt; TITLE]] of more test [[LINK:27654 
  ) 
  </code></pre>
  
  <p>Which isn't what I need.  Is there a simple way to extract the tags?  I'd really like to avoid iterating through the string and extracting manually.</p>