Displaying comments and replies retrieved from a database
It seems you wish to batch the posted messages together into threads.  In other words, create a "parent - children" relationship.  This can be achieved simply by using one loop to generate the new data structure and one smaller loop (I use array_map()) to display the text.

Code: (Demo)

foreach ($comments as $data) {
    if ($data['reply_id']!='') {
        $threads[$data['reply_id']][]="{$data['user']} reply: {$data['message']}";   // append element
    } else {
        if (!isset($threads[$data['id']])) {  // prevent Notice
            $threads[$data['id']] = [];
        }
        array_unshift($threads[$data['id']], "{$data['user']} comment: {$data['message']}");  // prepend element
    }
}

// display data (with no unwanted line breaks):
echo implode("&lt;br&gt;&lt;br&gt;", array_map(function($v){return implode("&lt;br&gt;",$v);}, $threads));


Output (same as your posted code provides):

Jan comment: hello
Jul reply: hello7
Jun reply: hello6

Mar comment: hello3
May reply: hello5

Feb comment: hello2
Apr reply: hello4


Some additional notes:


Using ORDER BY date DESC will place newer replies above older replies, be sure that this makes sense in terms of discussion "flow".
There appears to be data redundancy with id and comment_id.  If there is a difference between these two columns of data that doesn't present itself in your posted task, then they both can stay, otherwise you should omit one of these columns from your database.
A final consideration... when dealing with thread-based messages/posts/data, it simplifies tasks like these to assign a thread_id, then you can GROUP BY and/or ORDER BY the column in your SQL and spare much of the php handling.