title: php how to loop append to variable
body: <p>I have this PHP code that works:</p>
  
  <pre><code>for ($i=0; $i &lt; 5; $i++) {
      do stuff to $class
      echo "&lt;i class=\"glyphicon glyphicon-star $class\"&gt;&lt;/i&gt;";
  }
  </code></pre>
  
  <p>Instead of using <code>echo</code> in the loop, how would I append each iteration to a variable (say <code>$stars</code>) and then be able to display the result with</p>
  
  <pre><code>echo "$stars";
  </code></pre>