PHP: Is it programatically possible to append iterator value to array key name in loop? <p>I have a multidimensional array object, and in a loop I would like to append an iterator to the key and obtain the value. Sample code for demonstration:</p> <pre><code> $array_object-&gt;example1 = 1; $array_object-&gt;example2 = 2; $i = 1; while ($i &lt;= 2) { echo ($array_object-&gt;example . $i); //this does not work //how to accomplish same? $i++ } </code></pre> <p>Thank you in advance for any suggestions.</p>