如果您的
$result变量是字符串json之类的,则必须使用
json_deprefunction将其解析为 对象 或 数组 :
$result = '{"Cancelled":false,"MessageID":"402f481b-c420-481f-b129-7b2d8ce7cf0a","Queued":false,"SMSError":2,"SMSIncomingMessages":null,"Sent":false,"SentDateTime":"/Date(-62135578800000-0500)/"}';$json = json_depre($result, true);print_r($json);输出值
Array( [Cancelled] => [MessageID] => 402f481b-c420-481f-b129-7b2d8ce7cf0a [Queued] => [SMSError] => 2 [SMSIncomingMessages] => [Sent] => [SentDateTime] => /Date(-62135578800000-0500)/)
现在您可以将
$json变量作为数组使用:
echo $json['MessageID'];echo $json['SMSError'];// other stuff
参考文献:
- json_depre -PHP手册



