title: preg_replace(): "non-strict" replacement
body: <p>I have some string <code>$content</code>, which contains some px-metrics (<code>"&lt;div class="predefined" data-key="name" style="z-index: 1000; position: absolute; max-width: 556px; width: 556px;..."</code>). I need to multiply every found metric by some number.</p>
  
  <p>I decided to use <code>preg_replace()</code>: </p>
  
  <p>1) for first argument - patterns - I parsed string and got <code>$patterns</code> array with all px-metrics in string; after that added for every element delimiters <code>"/"</code>:</p>
  
  <pre><code>$patterns = array (
    0 =&gt; '/556px/',
    1 =&gt; '/556px/',
    2 =&gt; '/40px/',
    3 =&gt; '/1px/',
    4 =&gt; '/1px/',
    5 =&gt; '/556px/',
    6 =&gt; '/556px/',
    7 =&gt; '/40px/',
    8 =&gt; '/1px/',
    9 =&gt; '/280px/',
    10 =&gt; '/556px/',
    11 =&gt; '/20px/',
    12 =&gt; '/100px/',
    13 =&gt; '/40px/',
    14 =&gt; '/220px/',
    15 =&gt; '/480px/',
  );
  </code></pre>
  
  <p>2) second argument - <code>$replacements</code> - should be every metric from $patterns, multiplied by some num (in this case, num is 2.6978417266187051):</p>
  
  <pre><code>$replacements = array (
    0 =&gt; '1500px',
    1 =&gt; '1500px',
    2 =&gt; '107.91366906475px',
    3 =&gt; '2.6978417266187px',
    4 =&gt; '2.6978417266187px',
    5 =&gt; '1500px',
    6 =&gt; '1500px',
    7 =&gt; '107.91366906475px',
    8 =&gt; '2.6978417266187px',
    9 =&gt; '755.39568345324px',
    10 =&gt; '1500px',
    11 =&gt; '53.956834532374px',
    12 =&gt; '269.78417266187px',
    13 =&gt; '107.91366906475px',
    14 =&gt; '593.52517985612px',
    15 =&gt; '1294.964028777px',
  );
  </code></pre>
  
  <p>3) run <code>$content = preg_replace($patterns, $replacements, $content);</code></p>
  
  <p>I noticed problem with element[14]. There is a peace of result string:</p>
  
  <p><code>height: 107.91366906475px; bottom: auto; left: 253.956834532374px; top: 1294.964028777px;"&gt;111222&lt;/div&gt;</code></p>
  
  <p><code>left</code>, which should be <em>593.52517985612px</em>, is <em>253.956834532374px</em>! I see, why it occurs:</p>
  
  <p><em>2<strong>20px</em></strong> is replaced not by 15-th element, but particially by element[11] (<em>2<strong>20px</em></strong> => 2 + replace by element[11] => <em>2<strong>53.956834532374px</em></strong>).</p>
  
  <p>What can I do with that? My reg. expressions in <code>$patterns</code> are not in brackets, so I was waiting for strict comparison.</p>
  
  <p>If it cannot be resolved, I can use totally another approach for changing metrics in string, not exactly via <code>preg_replace()</code>, any help will be useful.</p>