如何获取PHP变量中的金额值。我在下面试过但是它不起作用
我会感谢你们给予的任何帮助
$event_json = json_decode($body);
$event_id = $event_json->id;
$amount = $event_json->data->amount;
{
"created":1326853478,
"data":{
"object":{
"amount":4500,
"card":{
"country":"US",
"cvc_check":"pass",
"exp_month":7,
"exp_year":2014,
"fingerprint":"9aQtfsI8a17zjEZd",
"id":"cc_00000000000000",
"last4":"9782",
"object":"card",
"type":"Visa"
},
"created":1322700852,
"currency":"usd",
"disputed":false,
"fee":0,
"id":"ch_00000000000000",
"livemode":false,
"object":"charge",
"paid":true,
"refunded":true
}
},
"id":"evt_00000000000000",
"livemode":false,
"type":"charge.refunded"
}
答案 0 :(得分:1)
看起来你只是缺少指向object
对象的指针:
$amount = $event_json->data->object->amount;
答案 1 :(得分:1)
data
内部元素称为object
,amount
是object
的一部分,因此您可能需要使用
$amount = $event_json->data->object->amount ;