[英]how to read json data indexed object in php
簡單的三行代碼:
$input = @file_get_contents("php://input");
$event_json = json_decode($input,true);
print_r($event_json);
我使用前 2 行將 json 數據轉換為 php 中的數組,第三行打印以下數組(我在此處顯示的部分):
Array
(
[created] => 1326853478
[livemode] =>
[id] => evt_00000000000000
[type] => charge.succeeded
[object] => event
[request] =>
[pending_webhooks] => 1
[api_version] => 2014-07-26
[data] => Array
(
[object] => Array
(
[id] => ch_00000000000000
[object] => charge
[amount] => 100
[amount_refunded] => 0
我的問題是:我如何回顯金額(即 100)或 amount_refunded(即 0)?
echo $event_json['data']['object']['amount'];
echo $event_json['data']['object']['amount_refunded'];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.