php - 获取数组 PHP 的内部部分
问题描述
如何在 PHP 中获取长数组的内部部分:示例:
print_r($array) 给出:
Razorpay\Api\Collection Object
(
[attributes:protected] => Array
(
[entity] => collection
[count] => 1
[items] => Array
(
[0] => Razorpay\Api\Payment Object
(
[attributes:protected] => Array
(
[id] => payid
[entity] => payment
[amount] => 1000
[currency] => INR
[status] => captured
[order_id] => orderid
[invoice_id] =>
[international] =>
[method] => card
[amount_refunded] => 0
[refund_status] =>
[captured] => 1
[description] => D.
[card_id] => id
[bank] =>
[wallet] =>
[vpa] =>
[email] => example@example.com
[contact] => +91
[notes] => Razorpay\Api\Payment Object
(
[attributes:protected] => Array
(
[address] => add
[merchant_order_id] => orid
)
)
[fee] => 20
[tax] => 0
[error_code] =>
[error_description] =>
[created_at] => 1580641472
)
)
)
)
)
这是返回的 Razorpay 付款详细信息。如何从这个数组中获取 id 和其他最里面的项目我想获取 id 和 status 并检查状态是否被捕获或未能验证付款,但是,我无论如何都无法得到它。请帮忙
解决方案
终于得到:
$payment = $api->order->fetch($_POST["razorpayorderid"])->payments();
$payid = $payment["items"][0]["id"];
推荐阅读
- discord.py - Discord.py 机器人门户
- javascript - 输入标签不会在反应中显示
- python - 我如何重建这个数据集,以便比较这两家公司?
- automation - 我可以用什么来使用 cypress 与本网站上的搜索栏进行交互
- numpy - 如何加载和重用以“.npy”格式保存的已保存嵌入
- python - 枚举整数列表并按索引访问列表值
- python - 通过 Twitch 用于桌面应用程序的 OAuth 2.0 授权令牌
- java - 使用 jsonpath 访问 json 值?
- css - @font-face 指向本地 URL 的链接不起作用
- sql-update - LARAVEL更新错误在null上调用成员函数update()