title: PHP doesn't replace variables with defined values in a String
body: <br>
  Here is a part of my PHP application:<br>
  <p><strong>Stage 1:</strong><br>I get an array of payment methods from user and assign an ID to it, because it can contain multiple choices.<br><br>I filled <code>$paymentMethod</code> variable with some examples. <br></p>
  <pre><code>$paymentMethod = ['PayPal','Visa','Master'];
  $paymentMethodNames = array(&quot;PayPal&quot;, &quot;Visa&quot;, &quot;Master&quot;, &quot;COD&quot;);
  $paymentMethodNumerical = array(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;);
  $paymentMethodCalculated = implode(str_replace($paymentMethodNames, $paymentMethodNumerical, $paymentMethod));
  </code></pre>
  <p>the result of <code>echo $paymentMethodCalculated</code> is <code>123</code> which is perfectly correct.<br></p>
  <p><strong>Stage 2:</strong><br>I need to create a special variable which is needed to work for another part of my application. <br></p>
  <pre><code>for ($x = 0; $x &lt; strlen($paymentMethodCalculated); $x++) {
  $paymentFinal .= '$_'.substr($paymentMethodCalculated, $x, 1);
      if(isset($paymentFinal) &amp;&amp; $x !== strlen($paymentMethodCalculated) - 1) {
         $paymentFinal .= '.&quot;,&quot;.';
      }
  }
  </code></pre>
  <p>The result of <code>echo $paymentFinal</code> is <code>$_1.&quot;,&quot;.$_2.&quot;,&quot;.$_3</code> which is perfectly correct.<br>
  <br><strong>Stage 3:</strong><br>Now I define:<br></p>
  <pre><code>$_1 = Test;
  $_2 = Test2;
  $_3 = Test3;
  </code></pre>
  <p>Now, when I echo <code>$paymentFinal</code><br>It still shows:<br> <code>$_1.&quot;,&quot;.$_2.&quot;,&quot;.$_3</code><br><br>But my desired result is:<br> <code>Test.&quot;,&quot;.Test2.&quot;,&quot;.Test3</code></p>
  <p><br><strong>Question:</strong>
  Why PHP does not replace defined variables in <code>$paymentFinal</code> variable?</p>