I have this function whose essential operations are outlined as follows:
function render($index) {
foreach($things[$index] as $key => $data) {
echo '<div>';
/* irrelevant operations */
if(isset($data['id'])) {
echo '<div class="wrap">';
render($things[$data['id']]);
echo '</div>';
}
echo '</div>';
}
}
I can not for the life of me figure out how to optimize this function; I fear that PHP implode if the call stack gets too big.
Is there any way to optimize this function?