I have a foreach loop which finds comment replies and stores them in $child_comments
After
<?php echo '<pre>';
print_r($child_comments);
echo '</pre>'; ?>
I get a separate array for each of the parent comments:
Array
(
[0] => stdClass Object
(
[comment_ID] => 603
[comment_parent] => 600
[user_id] => 2
)
[1] => stdClass Object
(
[comment_ID] => 601
[comment_parent] => 600
[user_id] => 2
)
)
Array
(
[0] => stdClass Object
(
[comment_ID] => 584
[comment_parent] => 580
[user_id] => 1
)
)
Array
(
[0] => stdClass Object
(
[comment_ID] => 608
[comment_parent] => 520
[user_id] => 2
)
[1] => stdClass Object
(
[comment_ID] => 598
[comment_parent] => 520
[user_id] => 2
)
[2] => stdClass Object
(
[comment_ID] => 521
[comment_parent] => 520
[user_id] => 2
)
)
But I need to sort and output the comments by their comment id, from highest ID to lowest ID.
I can get the comments I like with
foreach ($child_comments as $objects) {
echo $objects->comment_ID;
}
but still they will be sorted by their parent comments. Any ideas? The ideal structure would be something like this:
Array
(
[0] => stdClass Object
(
[comment_ID] => 608
[comment_parent] => 520
[user_id] => 2
)
[1] => stdClass Object
(
[comment_ID] => 603
[comment_parent] => 600
[user_id] => 2
)
[2] => stdClass Object
(
[comment_ID] => 601
[comment_parent] => 600
[user_id] => 2
)
[3] => stdClass Object
(
[comment_ID] => 598
[comment_parent] => 520
[user_id] => 2
)
[4] => stdClass Object
(
[comment_ID] => 584
[comment_parent] => 580
[user_id] => 1
)
[5] => stdClass Object
(
[comment_ID] => 521
[comment_parent] => 520
[user_id] => 2
)
)