json解码后无法访问数组的字符串元素

问题描述

这是我的解码数组代码

$transfer = '{"type": "BALANCE","status": "REJECTED"}'; $json = json_decode($transfer); echo $json->status;

它没有显示状态值。

如果我将状态更改为整数值。

$transfer = '{"type": "BALANCE","status": "1234"}';

然后它显示的状态值为 1234。

如果是字符串格式,如何显示状态值。

解决方法

这工作正常

<?php 

$transfer = '{"type": "BALANCE","status": "REJECTED"}'; 
$json = json_decode($transfer); 
echo $json->status; //displays REJECTED

?>