title: PHP how to declare object like $foo->$bar->$car
body: <p>I need to use an object like $foo->$bar->$car, where $bar and $car can assume a lot of values. How can I declare it?</p>
  
  <p>For example, I need to say:  </p>
  
  <pre><code>$foo-&gt;{'0'}-&gt;{'a'} = 2;  
  $foo-&gt;{'0'}-&gt;{'b'} = 4;  
  $foo-&gt;{'1'}-&gt;{'a'} = 8;  
  </code></pre>
  
  <p><strong>edit:</strong>
  $bar and $car can assume a lot of values each.</p>
  
  <p>Thank you in advance.</p>