get data from return value of mandrillapp array [duplicate]

假装没事ソ 提交于 2019-12-11 13:35:45

问题


Mandrill app return this : [{"email":"steven@gmail.com","status":"sent","_id":"234we4fvba4a3e8517d7a9","reject_reason":null}]

I need to get only the value of "status". Something like this: echo $result['status']; How can I do it in PHP?


回答1:


use json_decode() to get the status.. like this :

<?php

$str = '[{"email":"steven@gmail.com","status":"sent","_id":"234we4fvba4a3e8517d7a9","reject_reason":null}]';
$json = json_decode($str, true);
echo $json[0]['status'];

 ?>



回答2:


you can use like

$json = '[{"email":"steven@gmail.com","status":"sent","_id":"234we4fvba4a3e8517d7a9","reject_reason":null}]';
$json_array = json_decode($json);
print "<pre>";print_r($json_array[0]->status);


来源:https://stackoverflow.com/questions/37018951/get-data-from-return-value-of-mandrillapp-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!