Home > php教程 > php手册 > json的键名为数字时的调用方式(示例代码)

json的键名为数字时的调用方式(示例代码)

WBOY
Release: 2016-06-06 20:26:26
Original
1130 people have browsed it

json的键名为数字时的调用方式(示例代码)。需要的朋友可以过来参考下,希望对大家有所帮助

对于键名为数字或者非正常变量字符时(如有空格),必须使用obj[xx]方式获取值。

复制代码 代码如下:


//声明json数据
$array = array('result'=>array("90"=>"90队列","status"=>"成功"));
$json = json_encode($array);

$array1 = array("90"=>"90队列","status"=>"成功");
$json1 = json_encode($array1);
$phpjson = json_decode($json1,true);//第二个参数是true,,表示把json数据转换为数组
//对于json键名是数字时,只能用数组方式处理$phpjson['90'];
?>









Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template