JSON

php json()函数

字号+ 作者:H5之家 来源:H5之家 2015-10-09 09:05 我要评论( )

json()函数参数列表:函数描述json_encode对变量进行json编码json_decode对json格式的字符串进行解码,转换为php变量json_last_error返回最后发生的错误Forexa

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)

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • php CI 实战教程:[5]用curl获取json并解析

    php CI 实战教程:[5]用curl获取json并解析

    2016-02-26 17:00

  •  JSON入门级学习总结-JSON数据结构

    JSON入门级学习总结-JSON数据结构

    2016-02-25 11:05

  • Android解析Json速度最快的库:json

    Android解析Json速度最快的库:json

    2016-02-13 18:00

  • JavaScript转换与解析JSON方法实例详解第1/2页

    JavaScript转换与解析JSON方法实例详解第1/2页

    2016-02-10 21:25

网友点评
e