Php 从具有对象的复杂数组中获取值
这是请求的响应,但我要从这样的数组中获取值。我需要从这样的数组中获取支付url。PHP中的函数convert object to array。假设您在变量<代码> $x< /代码>中有这个对象,那么您应该这样做:Php 从具有对象的复杂数组中获取值,php,Php,这是请求的响应,但我要从这样的数组中获取值。我需要从这样的数组中获取支付url。PHP中的函数convert object to array。假设您在变量 $x< /代码>中有这个对象,那么您应该这样做: CoinGate\Merchant\Order Object ( [order:CoinGate\Merchant\Order:private] => Array ( [id] => 97977 [status
CoinGate\Merchant\Order Object
(
[order:CoinGate\Merchant\Order:private] => Array
(
[id] => 97977
[status] => new
[do_not_convert] =>
[price_currency] => USD
[price_amount] => 1200.0
[lightning_network] =>
[receive_currency] => EUR
[receive_amount] =>
[created_at] => 2018-07-03T05:53:43+00:00
[order_id] => 459469
[payment_url] => https://sandbox.coingate.com/invoice/94423345-1a1a-4895-a08e-98793777b0d0
[token] => x5Yrx5mmku8nkyK2ShVvbCuiJfasoxsNBtxZ27Ra
)
)
在一个文件中有一个神奇的\uu get
方法。因此,您应该使用它来获取所需的属性:
$y = get_object_vars($x);
echo $y['payment_url'];
这不起作用,它返回“未定义索引:顺序”直接作为
$y['payment\u url']
尝试,它已经说了private
,所以你不能直接指向它,也许你的对象有自己的getter函数来获取你想要的。我不完全确定你是否要发布一个数组,其中包含,这里有授权令牌。。我想不会。如果答案有助于解决您的问题,请随意接受。还有你的其他问题。
// suppose $response is the value you `var_dump`ed in a question.
echo $response->payment_url; // same for other properties: $response->status