You are here

function comment_delete_threading_tree in Comment Delete 7

Creates associative array of threaded comments.

Parameters

array $comments: Flat array of comment records.

int $pid: Parent ID used to recursively create array.

Return value

array Associative array of threaded comments.

1 call to comment_delete_threading_tree()
comment_delete_threading in ./comment_delete.module
Re-threads comments attached to an entity.

File

./comment_delete.module, line 354
comment_delete.module

Code

function comment_delete_threading_tree(array $comments, $pid = 0) {
  $branch = array();
  foreach ($comments as $comment) {
    if ($comment['pid'] == $pid) {
      $children = comment_delete_threading_tree($comments, $comment['cid']);
      if ($children) {
        $comment['children'] = $children;
      }
      $branch[] = $comment;
    }
  }
  return $branch;
}