title: remove last character from a string inside a loop in php
body: <p>i am trying to check whether VIN number is valid or not using PHP. I am using for loop as shown below</p>
  
  <pre><code> $base='**********';
  foreach ($params as $key =&gt; $value) {
      $query_string .= "$key=" . urlencode($value) . "&amp;";
      }
  $url = "$base?$query_string";
  </code></pre>
  
  <p>in this iam getting <strong><code>&amp;</code></strong> as last charecter like below</p>
  
  <pre><code>&amp;reportType=3&amp;
  </code></pre>
  
  <p>i tried to remove this using below code but its not working</p>
  
  <pre><code>substr($query_string, 0, -1);
   mb_substr($query_string, 0, -1);
  </code></pre>
  
  <p>Help me for remove last charecter </p>