php json相关函数用法示例
网络编程 2021-07-05 08:23www.168986.cn编程入门
这篇文章主要介绍了php json相关函数用法,列举了json_encode、json_decode及json_last_error的功能,并实例分析了json_encode与json_decode函数的具体使用技巧,需要的朋友可以参考下
本文实例讲述了php json相关函数用法。分享给大家供大家参考,具体如下:
函数列表:
函数 | 描述 |
---|---|
json_encode | 对变量进行json编码 |
json_decode | 对json格式的字符串进行解码,转换为php变量 |
json_last_error | 返回最后发生的错误 |
For example 1: json_encode
$arr=array("A"=>"a","B"=>"b","C"=>"c","D"=>"d"); echo json_encode($arr);
output:
{"A":"a","B":"b","C":"c","D":"d"}
For example 2: json_decode
$arr='{"A":"a","B":"b","C":"c","D":"d"}'; var_dump(json_decode($arr)); var_dump(json_decode($arr,true));
output:
object(stdClass)[1] public 'A' => string 'a' (length=1) public 'B' => string 'b' (length=1) public 'C' => string 'c' (length=1) public 'D' => string 'd' (length=1) array (size=4) 'A' => string 'a' (length=1) 'B' => string 'b' (length=1) 'C' => string 'c' (length=1) 'D' => string 'd' (length=1)
PS:这里再为大家推荐几款比较实用的json在线工具供大家参考使用:
在线JSON代码检验、检验、美化、格式化工具:
JSON在线格式化工具:
在线XML/JSON互相转换工具:
json代码在线格式化/美化/压缩/编辑/转换工具:
C语言风格/HTML/CSS/json代码格式化美化工具:
更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》及《》
希望本文所述对大家PHP程序设计有所帮助。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程