[英]How to read specific data from an object?
{"TransactionInfo":{"Date":"06\\/04\\/2018","Time":"09:29 ET","TransactionCharge":{"MonetaryValue":"0.00","CurrencyCode":{}}},"ShipmentEstimate":{"CurrencyCode":"EUR","ShipmentCharges":{"TaxesAndFees":"1.7532","AdditionalInsuranceCost":"0.00","TransportationCost":"0.00","SubTotal":"1.7532"},"ProductsCharges":{"Product":{"TariffCode":"5109.90.80.00","Charges":{"Duties":"75.0021","TaxesAndFees":"0.00","VAT":"0.00","CostOfGoods":"1250.00","SubTotal":"1325.0021"}},"ProductsSubTotal":"1325.0021"},"TotalLandedCost":"1326.7553"},"SuppressQuestionIndicator":"Y"}
如何僅獲取TariffCode的值? 結果必須是:5109.90.80.00
<?php
$json = '{"TransactionInfo":{"Date":"06\/04\/2018","Time":"09:29 ET","TransactionCharge":{"MonetaryValue":"0.00","CurrencyCode":{}}},"ShipmentEstimate":{"CurrencyCode":"EUR","ShipmentCharges":{"TaxesAndFees":"1.7532","AdditionalInsuranceCost":"0.00","TransportationCost":"0.00","SubTotal":"1.7532"},"ProductsCharges":{"Product":{"TariffCode":"5109.90.80.00","Charges":{"Duties":"75.0021","TaxesAndFees":"0.00","VAT":"0.00","CostOfGoods":"1250.00","SubTotal":"1325.0021"}},"ProductsSubTotal":"1325.0021"},"TotalLandedCost":"1326.7553"},"SuppressQuestionIndicator":"Y"}';
$array = json_decode($json, true);
echo $array['ShipmentEstimate']['ProductsCharges']['Product']['TariffCode'];
在此處查看其運行情況: https : //3v4l.org/2WBs6
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.