$comments = array(); Empty array of output.
while( $comment = $queryResults() ) For every comment in our query result...
if( in_array( $comment['profile_post'], array_keys( $comments ) ) If this profile_post (Which i assume is a UserID) has already commented on something...
$comments[ $comment['profile_post'] ] = $comment; Tack the comment on as an array element corresponding to his poster ID.
$comments[ $comment['profile_post'] ] = array(); He hasnt posted anything yet, but he is now. So we create an empty array to hold his comments, using his profile_post as a key.
$comments[ $comment['profile_post'] ] = $comment; And tack the first comment he made (the current one) into it.
Note that this could have been condensed into a single line by pushing $comment into the array definition above.