2016-07-22 56 views
-2

我有一個API,它以數組的形式返回響應。我想從這個數組中提取元素並將它們保存在我的數據庫中。我曾嘗試使用爆炸功能,但似乎我缺少一些東西。以下是來自檢索的確切示例響應。如何將數組值複製到單個變量中

Array 
(
[Response] => Array 
    (
     [external_reference] => bablaba 
     [withdraw_request_id] => babalalal 
     [amount] => bababababa 
     [status] => ababababab 
     [message] => ababababa. 
     [new_balance] => babababa 
     [amount_sent] => ababababa 
     [currency_sent] => ababababa 
     [charge_amount] => ababababa 
     [charge_currency] => babababa 
     [currency] => abababaab 
    ) 

) 
+1

郵編你已經嘗試 – Apb

+0

$ new_variable = $陣列[ '響應'] [ '貨幣']; echo $ new_variable; – JYoThI

回答

0

重複變量有什麼意義?

當你要保存的量爲例使用$array['response']['amount']

0

已在陣列$Array裏的數組Response。爲了將數組元素值轉換成變量。您必須導航$Array內部和Response內部這樣做,你寫:$bigArray['smallArray']['element']

$external_reference = $Array['Response']['external_reference']; 
$withdraw_request_id = $Array['Response']['withdraw_request_id']; 
$amount = $Array['Response']['amount']; 
$status = $Array['Response']['status']; 
$message = $Array['Response']['message'];. 
$new_balance = $Array['Response']['new_balance']; 
$amount_sent = $Array['Response']['amount_sent']; 
$currency_sent = $Array['Response']['currency_sent']; 
$charge_amount = $Array['Response']['charge_amount']; 
$charge_currency = $Array['Response']['charge_currency']; 
$currency = $Array['Response']['currency']; 

要了解更多關於多維數組閱讀:this

相關問題