This code should work:
<?php
$result = array();
$arr = $arr[0];
while (is_array($arr['comments']) {
$el = $arr;
unset($el['comments']);
$result[] = $el;
if (isset($arr['comments'])) {
$arr = $arr['comments'];
}
else {
break;
}
}
You haven't provided data in PHP so I couldn't test it. However this code is definitely not optimal.
If you sure about fields you have in your array I strongly recommend to change lines:
$el = $arr;
unset($el['comments']);
$result[] = $el;
into
$el['comment_id'] = $arr['comment_id'];
$el['user_id'] = $arr['user_id'];
// and so on until
$el['comment_likes'] = $arr['comment_likes'];
Another solution will be creating extra loop but this solution should be enough in your case.