Answer the question
In order to leave comments, you need to log in
How to convert json to a specific form?
I collect an array in a loop from the database
$data[] = [
'proto' => $protos[$protoid],
'localip' => long2ip($row['nIPv4Left']),
'port' => $row['nPortLeft']
];
[
{"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}
]
{
"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}
]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question