当前位置:网站首页>二维格式数组格式索引下标连续问题导致 返回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【二进制】
- Awk from getting started to getting into the ground (3) the built-in functions printf and print of awk realize formatted printing
- Distributed transaction solution
- Gbase 8C system table PG_ amop
- 机器学习流程与方法
- [shutter] banner carousel component (shutter_wiper plug-in | swiper component)
- Build a private cloud disk cloudrev
- [Yu Yue education] China Ocean University job search OMG reference
- GBase 8c系统表pg_cast
- 【翻译】Flux安全。通过模糊处理获得更多信心
猜你喜欢

udp接收队列以及多次初始化的测试

内存池(内核角度理解new开辟空间的过程)
![[Flutter] dart: class;abstract class;factory;类、抽象类、工厂构造函数](/img/06/ab333a4752de27eae2dd937cf579e2.png)
[Flutter] dart: class;abstract class;factory;类、抽象类、工厂构造函数

基于线程池的生产者消费者模型(含阻塞队列)

elastic stack

4. 类和对象

Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution

Return a tree structure data

Mathematical statistics -- Sampling and sampling distribution

where 1=1 是什么意思
随机推荐
Summary of interview project technology stack
Gbase 8C system table PG_ attribute
where 1=1 是什么意思
Awk from getting started to being buried (2) understand the built-in variables and the use of variables in awk
GBase 8c 创建用户/角色 示例二
GBase 8c系统表-pg_authid
微服务组件Sentinel (Hystrix)详细分析
easyPOI
Startup mode and scope builder of collaboration in kotlin
cvpr2022去雨去雾
javeScript 0.1 + 0.2 == 0.3的问题
搭建私有云盘 cloudreve
How to change the panet layer in yolov5 to bifpn
[Yu Yue education] reference materials of love psychology of China University of mining and technology
[Yu Yue education] reference materials of chemical experiment safety knowledge of University of science and technology of China
Simple understanding of SVG
Detailed introduction to the usage of Nacos configuration center
elastic stack
Gbase 8C trigger (III)
Gbase 8C system table PG_ amproc