title: php preg_replace array but only in the initial string
body: <p>This scripts</p>
  
  <pre><code>&lt;?php
  $pat = array ( '/A/', '/B/');
  $rep = array ( 'B', 'C');
  print preg_replace($pat, $rep, 'AAB');
  ?&gt;
  </code></pre>
  
  <p>I would liket to print 'BBC' ('B' replaces 'A' and 'C' replaces only the initials 'B')</p>
  
  <p>But it prints 'CCC' ('B' replaces 'A' and 'C' replaces 'B' and the 'A' previously replaced by 'B')</p>
  
  <p>If I tried something like this script </p>
  
  <pre><code>&lt;?php
  $pat = array ( '/A/', '/B/');
  $rep = array ( 'B', 'C');
  print preg_replace($pat, $rep, 'AAB', 1);
  ?&gt;
  </code></pre>
  
  <p>But it prints 'CAB'...</p>
  
  <p>Thanks.</p>