Reputation: 8705
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?
Upvotes: 1
Views: 71
Reputation: 1718
On line 10, you call show_comments() but you don't concatenate result.
$comments_list .= $this->show_comments($comments, $comment['id_comment']);
Upvotes: 2