PHP loop optimization

nouter

New Member
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.\[code\]public function getHTML() { $phpObj = json_decode($this->data); // array(object, object, object, ....); $table = "<table><tbody>\n"; if (count($phpObj->query->results->row) > 0) { $row = $phpObj->query->results->row; foreach ($row as $value) { $table .= "<tr>\n"; foreach ($value as $key => $val) { // concerned about loop inside loop $table .= "<td>" . $value->$key . "</td>"; } $table .= "\n</tr>\n"; } $table .= "</tbody></table>"; return $table; } else { return 'HTML table not created.'; } }\[/code\]Is there a more efficient way of traversing through the array and objects without creating a loop inside a loop?
 
Back
Top