我如何才能获得ID值
像
$ fo =" 11890408&#34 ;;
{"success":true,"result":{"success":[{"id":"11890408","device_id":"17183","message":"okey","status":"pending","send_at":1455046054,"queued_at":0,"sent_at":0,"delivered_at":0,"expires_at":1455049654,"canceled_at":0,"failed_at":0,"received_at":0,"error":"","created_at":1455046054,"contact":{"id":"2522330","name":"923336458112","number":"923336458112"}}],"fails":[]}}
答案 0 :(得分:1)
将json字符串转换为php数据结构,然后浏览对象和数组的数据树:
$json = '{
"success":true,
"result":{
"success[
{
"id":"11890408",
"device_id":"17183",
"message":"okey",
"status":"pending",
"send_at":1455046054,
"queued_at":0,
"sent_at":0,
"delivered_at":0,
"expires_at":1455049654,
"canceled_at":0,
"failed_at":0,
"received_at":0,
"error":"",
"created_at":1455046054,
"contact":{
"id":"2522330",
"name":"923336458112",
"number":"923336458112"
}
}
],
"fails":[]
}
}';
$data = json_decode($json);
$fo = $data->result->success[0]->id;