title: How to remove the last character from last string in a While loop?
body: <p>I am trying to insert a PHP loop with data from my mysql database inside a Google Charts script.</p>
  <p>My result from the database looks like this:</p>
  <pre><code>$result = $wpdb-&gt;get_results(
      &quot;Query&quot;); 
  </code></pre>
  <p>The loop that I am trying to make is supposed to look like this</p>
  <pre><code>['$result',  $result],
  </code></pre>
  <p>And this is what I have come up with so far</p>
  <pre><code>$count = 0;
  while ($count &lt; count($result)) {
      echo &quot;['&quot; . $result[$count]-&gt;dato . &quot;', &quot; . $result[$count]-&gt;vaegt . &quot;].&lt;br&gt;&quot;;
      $count++;
      }
  </code></pre>
  <p>Which create the string that I am looking for. The problem is that I need to remove the comma from the last string in the loop.</p>
  <p>I have tried the function LTRIM, but it removes it from every string in the loop, not just the last.</p>
  <p>What would be the best solution to fix this problem?</p>