title: Concatanation in php
body: <p>I have the next situation, lets say i have an object with 10 attributes, named r1, r2, r3...r10. Now i want to extract the value of each attribute dynamically. for that i make a for like this and know it will work </p>
  
  <pre><code>$sum = 0;
  
  for($i = 1; $i &lt;= 10; $i ++){
  $key = "r{$i}";
  $sum += $this-&gt;$key;
  }
  </code></pre>
  
  <p>This is a representative example, what i want to know is if instead of doing that, i could do something like</p>
  
  <pre><code>for($i = 1; $i &lt;= 10; $i ++){
  
  $sum += $this-&gt;r{$i};
  }
  </code></pre>
  
  <p>and take the extra line off... i have tried several forms of concatenate this like that but i cant figure it out. Can any one tell me if it is possible and how.</p>