我有一个以数组形式返回响应的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
)
)
答案 0 :(得分:0)
复制变量有什么意义?
如果要保存例如使用$array['response']['amount']
答案 1 :(得分:0)
数组Response
中有一个数组$Array
。为了将数组元素值转换为变量。您必须在$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