当前位置:网站首页>二维格式数组格式索引下标连续问题导致 返回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;
边栏推荐
- Gbase 8C system table PG_ conversion
- awk从入门到入土(1)awk初次会面
- [hcia]no.15 communication between VLANs
- 簡單理解svg
- GBase 8c系统表-pg_class
- 内存池(内核角度理解new开辟空间的过程)
- [translation] flux is safe. Gain more confidence through fuzzy processing
- [shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)
- Kotlin middle process understanding and Practice (II)
- 【CodeForces】CF1338A - Powered Addition【二进制】
猜你喜欢
![[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)](/img/65/c1fe95f8c391394f7ff1b75c7d75b6.jpg)
[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)
![[translation] modern application load balancing with centralized control plane](/img/b0/22e9bf098d580b2af67255ddcdc0d5.jpg)
[translation] modern application load balancing with centralized control plane
![[translation] the background project has joined the CNCF incubator](/img/0b/e3d2674b1a1cba3ea398cbcb1a018a.png)
[translation] the background project has joined the CNCF incubator

【翻译】后台项目加入了CNCF孵化器

通达OA 首页门户工作台

《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨

【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)

Summary of interview project technology stack

Solution for processing overtime orders (Overtime unpaid)

Basic operation of binary tree (C language version)
随机推荐
Kotlin middle process understanding and Practice (II)
Gbase 8C function / stored procedure definition
Detailed introduction to the deployment and usage of the Nacos registry
[Yu Yue education] China Ocean University job search OMG reference
Startup mode and scope builder of collaboration in kotlin
Use go language to realize try{}catch{}finally
Awk from entry to burial (1) awk first meeting
[translation] modern application load balancing with centralized control plane
GBase 8c系统表-pg_amproc
[hcia]no.15 communication between VLANs
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)
Unrecognized SSL message, plaintext connection?
Gbase 8C system table PG_ auth_ members
Return a tree structure data
简单理解svg
Recommendation letter of "listing situation" -- courage is the most valuable
Detailed introduction to the usage of Nacos configuration center
Basic operation of binary tree (C language version)
awk从入门到入土(0)awk概述
[shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)