title: add a counter variable to a variable name
body: <p>I don't understand how one can add a counter variable content to the name of another variable. Although I realized that my problem could be solved more elegantly with the use of arrays, I want to use the counter in the variable name.</p>
  
  <p>My code looks like this so far:</p>
  
  <pre><code>    &lt;?php
          $f2 = bla2;
          $f3 = bla3;
  </code></pre>
  
  <p>....</p>
  
  <pre><code>        $f13 = bla13;
          $f14 = 0;
          echo $f2;
          for($j = 3; $j &lt;= 14; ++$j){
          if (!empty('$f'.$j)){
          echo(', ');
          eval('print $f'.$j.';');
          };
       };
       ?&gt;
  </code></pre>
  
  <p>I want to give output for every $f and also check if it's empty before I echo it. The for loop already worked before adding the if condition. I assume that I don't name the variable correctly inside the if condition and I have no clue how to do it, as this code doesn't work as it is now.</p>
  
  <p>I would also like to know, if I could include the if condition into the for loop.
  I already tried to apply the solutions to these questions</p>
  
  <p><a href="https://stackoverflow.com/questions/4327218/access-a-variable-using-a-counter-as-part-of-the-variable-name">Access a variable using a counter as part of the variable name</a></p>
  
  <p><a href="https://stackoverflow.com/questions/12664712/add-counter-to-the-end-of-variables/12664734#12664734">Add counter to the end of variables?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/4990901/use-counter-as-part-of-variable/4990922#4990922">Use counter as part of variable</a></p>
  
  <p>but had no success so far. Maybe someone finds my mistake here.</p>