Собираю массив в цикле из БД
$data[] = [
'proto' => $protos[$protoid],
'localip' => long2ip($row['nIPv4Left']),
'port' => $row['nPortLeft']
];
преобразовываю в json
echo json_encode($data);
получаю такой вид
[
{"proto":null,"localip":"0.0.0.222","port":11018},
{"proto":null,"localip":"192.168.69.138","port":41752},
{"proto":null,"localip":"0.0.0.76","port":46907},
{"proto":null,"localip":"0.0.0.244","port":26114},
{"proto":null,"localip":"0.0.0.242","port":1112}
]
а как преобраpовать его в такой json
{
"data":
[
{"proto":null,"localip":"0.0.0.222","port":11018},
{"proto":null,"localip":"192.168.69.138","port":41752},
{"proto":null,"localip":"0.0.0.76","port":46907},
{"proto":null,"localip":"0.0.0.244","port":26114},
{"proto":null,"localip":"0.0.0.242","port":1112}
]
}