title: regex for PHP preg_replace_callback
body: <p>Regular expressions is just not my thing. :(</p>
  
  <p>I have a string that may contain multiple sub strings such as:</p>
  
  <pre><code>[var1="111" var2="222" var3="222" var4="444"]
  </code></pre>
  
  <p>I basically need to replace each occurrence with the results of a function that gets each variable.</p>
  
  <pre><code>$string = '[var1="111" var2="222" var3="333" var4="444"]';    
  $regex = 'var1="(.*)" var2="(.*)" var3="(.*)" var4="(.*)"';
  
  function doit($matches){
      return "&lt;strong&gt;".implode(", ", $matches) ."&lt;/strong&gt;";
  }
  
  echo preg_replace_callback($regex,'doit',$string);
  </code></pre>
  
  <p>I’m expecting <strong>111, 222, 333, 444</strong>.</p>
  
  <p>But I’m not feeling the love. Any help would be appreciated!</p>
  
  <p><strong>Edit: some clarification..</strong> </p>
  
  <p>I was simplifying for the sake of the question. </p>
  
  <ol>
  <li><p>the "vars" will not really be
  called "var1", "var2" more like 
  [recID="22" template="theName"
  option="some value", type="list"] </p></li>
  <li><p>the call back would be more
  complicated then my simple
  implode... I would use "id" and
  connect to a database, get the
  records and insert them into the
  template... Hence the need for the
  call back... </p></li>
  <li><p>matched values could be almost
  anything, not just numbers.</p></li>
  </ol>