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

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

WBOY
WBOYOriginal
2016-05-17 08:52:55853browse

对于键名为数字或者非正常变量字符时(如有空格),必须使用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'];
?>









Statement:
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