json_encode和json_decode
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json));
var_dump(json_decode($json, true));
?>
object(stdClass)#1 (5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
可以看出 json_decode($data,true)输出的一个关联数组,由此可知json_decode($data)输出的是对象,而json_decode("$arr",true)是把它强制生成PHP关联数组.
json_encode和json_decode的更多相关文章
- php中的json_encode()和json_decode()函数的一些说明
一,json语法( php中的json_decode($json)中的$json要符合json语法格式 ) ① JSON可以表示三种类型的值 1,简单值.包括整型,字符串型,布尔值和null.例如:5 ...
- php json_encode()和json_decode()
json_encode()和json_decode()分别是编译和反编译过程 注意json只接受utf-8编码的字符,所以json_encode()的参数必须是utf-8编码,否则会得到空字符或者nu ...
- PHP数组和Json之间的互相转换 json_encode() 和 json_decode()
之所以要用到Json,很多时候是因为使用ajax对象时,程序与JS函数之间的数据交互.因为JS不认识PHP中的数组,PHP也不认识JS中的数组或对象.Json很好的解决了这个问题. Json简介 JS ...
- json_encode和json_decode和isset和array_key_exists
1.json_decode() json_decode — 对 JSON 格式的字符串进行编码 说明 mixed json_decode ( string $json [, bool ...
- ecshop类的解析2 json_encode和json_decode的具体实现
在看ecshop源码时,看到json这个类,研究了一下,它是为了兼容低版本php而做出的类,是对php的数据和json转换时使用的. encode和decode函数是对json的操作,对应json_e ...
- PHP开发笔记(二)PHP的json_encode和json_decode问题
解决PHP的json_encode问题之前,先了解一下PHP预定义常量http://php.net/manual/zh/json.constants.php. 用PHP的json_encode来处理中 ...
- php自定义json_encode()和json_decode()函数
json数据大家应该遇到过,json_encode()和json_decode()是php5.0以后加上的内置函数,如果低版本要使用,需加扩展,很多时候我们无权改变服务器的配置,我们只能通过自定义函数 ...
- json_encode() 和 json_decode()
php json_decode返回数据js的处理,json_decode后,返回到前台的数据如:encode_str => {"green":10,"size&qu ...
- 转载--PHP json_encode() 和json_decode()函数介绍
转自:http://www.nowamagic.net/php/php_FunctionJsonEncode.php 转自:http://www.jb51.net/article/30489.htm ...
- php 中利用json_encode和json_decode传递包括特殊字符的数据
</pre><span style="font-size:24px"></span><pre name="code" ...
随机推荐
- ASP.NET MVC电子书下载
欢迎点击图片下载电子书,进行深入的研究. ( ,)
- Selenium 获取隐藏元素的内容
第一种 先获取元素通过 属性获取 WebElement webElemt= webElement.findElement(By.xpath("//*[@class='xxxxxx]/a&qu ...
- 整理一下以前的Html+css3复习笔记
一.html5新特性 常用语义标签:nav footer header section mark 功能标签 video audio iframe canvas(画布和绘图功能) input新ty ...
- 51nod 1051 最大子矩阵和(dp)
题目链接:51nod 1051 最大子矩阵和 实质是把最大子段和扩展到二维.读题注意m,n... #include<cstdio> #include<cstring> #inc ...
- spring boot注解 --@EnableAsync 异步调用
EnableAsync注解的意思是可以异步执行,就是开启多线程的意思.可以标注在方法.类上. @Component public class Task { @Async public void doT ...
- iOS开发UI篇—直接使用UITableView Controller
iOS开发UI篇—直接使用UITableView Controller 一.一般过程 // // YYViewController.h // UITableView Controller // // ...
- .htaccess应该放在哪里?
根据 Apache 官方的介绍,.htaccess 文件属于分布式配置文件,可以放置在网站 www 根目录的所有子目录.以及 www 根目录的上一级目录中,生效的路径总是当前目录及其所有子目录(可在文 ...
- Rhel6-varnish配置文档
系统环境: rhel6 x86_64 iptables and selinux disabled 主机: 192.168.122.160:virnish apache server60.example ...
- ajax 创建对象验证
function getValue(){ var str = $("#selectid option:selected").val(); //获得选中的值 var num = $( ...
- jboss入门学习1
环境准备 win8 jdk1.6 jboss4.0.5 oracle10g 修改jboss默认端口 server/default/conf/jboss-service.xml 1.WebService ...