PHP loop optimization
<p>I have a php method that creates an HTML table with data it retrieves from a property.
My biggest concern is the performance of my application because I deal with a large amount of data.</p>

<pre><code>public function getHTML() {

    $phpObj =  json_decode($this-&gt;data); // array(object, object, object, ....);

    $table = "&lt;table&gt;&lt;tbody&gt;\n";

    if (count($phpObj-&gt;query-&gt;results-&gt;row) &gt; 0) {
        $row = $phpObj-&gt;query-&gt;results-&gt;row;

         foreach ($row as $value) {
            $table .= "&lt;tr&gt;\n";
            foreach ($value as $key =&gt; $val) { // concerned about loop inside loop
                $table .= "&lt;td&gt;" . $value-&gt;$key . "&lt;/td&gt;"; 
            }
            $table .= "\n&lt;/tr&gt;\n";
        }   

        $table .= "&lt;/tbody&gt;&lt;/table&gt;";
        return $table;
    }
    else {
        return 'HTML table not created.';
    }       
}
</code></pre>

<p>Is there a more efficient way of traversing through the array and objects without creating a loop inside a loop?</p>
