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

WBOY
Release: 2016-05-17 08:52:55
Original
880 people have browsed it

对于键名为数字或者非正常变量字符时(如有空格),必须使用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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!