当前位置:网站首页>二维格式数组格式索引下标连续问题导致 返回json 格式问题
二维格式数组格式索引下标连续问题导致 返回json 格式问题
2022-07-03 02:31:00 【qq_27878777】
1. 数组下标连续 返回json 格式不带索引
[
0=>[
'id'=>1,
'title'=>'测试一',
],
1=>[
'id'=>1,
'title'=>'测试一',
],
2=>[
'id'=>1,
'title'=>'测试一',
],
]
{
"msg": "ok",
"data": [
{
"id": 1,
"title": "测试一"
},
{
"id": 1,
"title": "测试一"
},
{
"id": 1,
"title": "测试一"
}
]
}
2. 数组下标不连续 , 返回json格式带索引
[
0=>[
'id'=>1,
'title'=>'测试一',
],
2=>[
'id'=>1,
'title'=>'测试一',
],
5=>[
'id'=>1,
'title'=>'测试一',
],
];
{
"msg": "ok",
"data": {
"0": {
"id": 1,
"title": "测试一"
},
"2": {
"id": 1,
"title": "测试一"
},
"5": {
"id": 1,
"title": "测试一"
}
}
}
3. 解决办法 重置索引连续
//重置连续索引
$lst = array_slice($lst, 0, count($lst), false);
return $lst;
边栏推荐
- [codeforces] cf1338a - Powered addition [binary]
- Cfdiv2 fixed point guessing- (interval answer two points)
- easyPOI
- Pytorch convolution network regularization dropblock
- 【CodeForces】CF1338A - Powered Addition【二进制】
- Leetcode (540) -- a single element in an ordered array
- easyExcel
- 【翻译】Flux安全。通过模糊处理获得更多信心
- Memory pool (understand the process of new developing space from the perspective of kernel)
- Word word word
猜你喜欢

Detailed introduction to the usage of Nacos configuration center
![[shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)](/img/6e/67bc187a89fb9125856c78c89f7bfb.gif)
[shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)

Job object of collaboration in kotlin

SPI机制

Detailed introduction to the deployment and usage of the Nacos registry
![[shutter] banner carousel component (shutter_wiper plug-in | swiper component)](/img/a6/5c97ef3f34702b83ebf0511501d757.gif)
[shutter] banner carousel component (shutter_wiper plug-in | swiper component)

MATLAB小技巧(24)RBF,GRNN,PNN-神经网络

搭建私有云盘 cloudreve

RestCloud ETL 跨库数据聚合运算

elastic stack
随机推荐
Awk from entry to burial (1) awk first meeting
Gbase 8C function / stored procedure definition
easyExcel
random shuffle注意
通达OA v12流程中心
Oauth2.0 authentication, login and access "/oauth/token", how to get the value of request header authorization (basictoken)???
Cvpr2022 remove rain and fog
awk从入门到入土(3)awk内置函数printf和print实现格式化打印
各国Web3现状与未来
[Flutter] dart: class;abstract class;factory;类、抽象类、工厂构造函数
Apple releases MacOS 11.6.4 update: mainly security fixes
GBase 8c 触发器(一)
[translation] modern application load balancing with centralized control plane
Gbase 8C create user / role example 2
GBase 8c系统表pg_cast
简单理解svg
Thread safe singleton mode
Cancellation of collaboration in kotlin, side effects of cancellation and overtime tasks
Tongda OA V12 process center
Gbase 8C system table PG_ conversion