title: Preg_replace with array replacements
body: <pre><code>$string = ":abc and :def have apples.";
  $replacements = array('Mary', 'Jane');
  </code></pre>
  
  <p>should become:</p>
  
  <pre><code>Mary and Jane have apples.
  </code></pre>
  
  <p>Right now I'm doing it like this:</p>
  
  <pre><code>preg_match_all('/:(\w+)/', $string, $matches);
  
  foreach($matches[0] as $index =&gt; $match)
     $string = str_replace($match, $replacements[$index], $string);
  </code></pre>
  
  <p>Can I do this in a single run, using something like preg_replace?</p>