Php 如何将数组值检索到单个变量中
我有一个API,它以数组的形式返回响应。我想从这个数组中提取元素并将它们保存在我的数据库中。我尝试过使用explode函数,但似乎遗漏了一些东西。下面是来自检索的精确示例响应Php 如何将数组值检索到单个变量中,php,arrays,Php,Arrays,我有一个API,它以数组的形式返回响应。我想从这个数组中提取元素并将它们保存在我的数据库中。我尝试过使用explode函数,但似乎遗漏了一些东西。下面是来自检索的精确示例响应 Array ( [Response] => Array ( [external_reference] => bablaba [withdraw_request_id] => babalalal [amount] => bababababa
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
)
)
复制变量有什么意义
例如,当您想保存金额时,请使用
$array['response']['amount']
在数组$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'];
要了解有关多维数组的更多信息,请阅读:PostCode,您已尝试$new_variable=$array['response']['currency'];echo$new_变量;