$res = [];
foreach($sqlResult as $row) {
if(!array_key_exists($row['id'], $res) {
$res[$row['id']] = [
'id' => $row['id'],
'name' => $row['name'],
'requests_params' => []
];
}
$res[$row['id']]['requests_params'][] = [
'fio' => $row['fio'],
'rid' => $row['rid']
];
}
echo json_encode(array_values($res));