title: Storing a PHP loop as a string in a variable
body: <p>I have a problem storing a PHP loop in a variable.</p>
  
  <p>The loop is like this:</p>
  
  <pre><code>for( $i = 1; $i &lt;= 10; $i++ ) {
  
      echo $i . ' - ';
  
  }
  </code></pre>
  
  <p>for this it's OK for an <code>echo</code> or <code>print</code> as it will produce:</p>
  
  <blockquote>
    <p>1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 -</p>
  </blockquote>
  
  <p>now I want to store the whole loop in a variable like <code>$my_var</code> which means:</p>
  
  <pre><code>echo $my_var;
  </code></pre>
  
  <p>which will produce:</p>
  
  <blockquote>
    <p>1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 -</p>
  </blockquote>
  
  <p>the whole idea is that I want to make the loop, store it as a string in a variable <code>$my_var</code>, than use it later in my script.</p>