php中json_encode转化笔记
来源:互联网 发布:知己知皮下一句是什么 编辑:程序博客网 时间:2024/05/16 08:10
PHP支持两种数组,一种是只保存”值”(value)的索引数组(indexed array),另一种是保存”名值对”(name/value)的关联数组(associative array)。
由于javascript不支持关联数组,所以json_encode()只将索引数组(indexed array)转为数组格式,而将关联数组(associative array)转为对象格式。
比如,现在有一个索引数组
结果为:
[“one”,”two”,”three”]
如果将它改为关联数组:
结果就变了:
{“1”:”one”,”2”:”two”,”3”:”three”}
如果获得下面的格式:
var config=[{ "id": "index", "homePage": "main", "menu": [{ "text": "测试", "items": [{ "id": "main", "text": "首页", "href": "Index/index" }] },{ "text": "测试2", "items": [{ "id": "main2", "text": "首页", "href": "Index/index" }] } ] }];
当前只会用嵌套数组方法
$menu=array(array(id=>’index’,homePage=>’main’,menu=>array(array(text=>’测试’,items=>array(array(id=>’main’,text=>’首页’,href=>’Index/index’))))));
0 0
- php中json_encode转化笔记
- php中json_encode注意
- php中json_encode注意
- php中对于json_decode()和json_encode()的使用方法笔记
- PHP中调用json_encode()函数
- php中json_decode()和json_encode()
- PHP json_encode
- PHP json_encode
- php json_encode
- php json_encode
- PHP-json_encode
- PHP json_encode
- PHP json_encode()
- json_encode.php
- php json_encode()
- php中json_decode()和json_encode()的使用方法
- PHP中json_encode返回null的原因
- php中json_decode()和json_encode()的使用方法
- 使用第三方工具Cornerstone搭建本地SVN服务器
- Shiro权限框架简介
- eclipse下的JAVA工程使用RXTX开发配置
- 汪国新委员:加强城市历史文化遗迹的恢复与开发
- 蓝桥杯 ADV-181 算法提高 质因数2
- php中json_encode转化笔记
- java基础_day0010_循环_for
- 蓝桥杯 ADV-182 算法提高 前10名
- 520.Detect Capital
- 创建swap
- React-native开发之图标库react-native-vector-icons 的集成使用
- 453. Minimum Moves to Equal Array Elements
- 计算机视觉之人脸检测算法——Haar分类器
- 华师大 OJ 2966