I have function like this:
function show_comments(&$comments, $parent_id = 0) {
$comments_list = "<ul>\n";
foreach($comments as $comment) :
if ($comment["parent_id"] != $parent_id)
continue;
$comments_list .= "<li>\n<h2>{$comment['id_comment']}</h2>\n";
$comments_list .= "<p>$comment[body]</p>\n";
$this->show_comments($comments, $comment['id_comment']);
$comments_list .= "</li>\n";
endforeach;
$comments_list .= "</ul>\n";
return $comments_list;
}
At the moment this function is returning only one result (the first one). How can I bind all result and return them?
$commentsyou have more than 1 comment and those comments' parent_id are different that$parent_idpassed as parameter (or 0 if none given)?