如何检索从PHP对象数组中的项? [英] How do I retrieve an item from an PHP Object Array?
问题描述
我想从这个数组检索数量。
发票对象
(
[数据:私人] =>排列
(
[I_STATUS] =>挂起
[i_title] => 500 HLCoins,500 HLCoins X8
[i_member] => 1
[i_items] =>排列
(
[0] =>排列
(
[动作] =>新
[应用] =>关系
[类型] = GT;产品
[费用] => 0
[税] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[数量] => 1
[物理] =>
[运输] =>排列
(
)
[重量] => 0
[ITEMNAME] => 500 HLCoins
[ITEMID] => 3
[cfields] =>排列
(
)
[额外] =>
[opt_id] => 0
[相关] =>
[assocBought] =>
[GROU prenewals] => 0
[方法] =>排列
(
)
[K] => 0
[_tax] => 0
)
[1] =>排列
(
[动作] =>新
[应用] =>关系
[类型] = GT;产品
[费用] => 0
[税] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[数量] => 8
[物理] =>
[运输] =>排列
(
)
[重量] => 0
[ITEMNAME] => 500 HLCoins
[ITEMID] => 3
[cfields] =>排列
(
)
[opt_id] => 0
[GROU prenewals] => 0
[方法] =>排列
(
)
[_tax] => 0
)
)
[i_total] => 0
[i_date] => 1347217384
[i_return_uri] =>
[i_paid] => 0
[i_status_extra] =>答:1:{S:4:类型; S:4:零;}
[i_discount] => 0
[i_temp] =>
[i_ordersteps] => 0
[i_noreminder] => 1
[i_renewal_ids] =>排列
(
)
[i_po] =>
[i_notes] =>
[i_shipaddress] =>
[i_id] => 229
)
[takeAction] => 1
)
我试过C $ CS一堆$像$ invoice->量,$发票[1] - >量,这$ - > $ invoice->的数量,但他们都不显示。 p>
它仍然不会显示在所有,我试图print_r的,这是它给我的数组。
好像所有的数据都在私人
属性。你不能从外部直接访问它。
阅读类的文档。它应该有一些方法可以调用,如 getQuantity()
,即会得到你的数据。这取决于类是如何写的,它是按照正确的方式使用。
I want to retrieve quantities from this array.
invoice Object
(
[data:private] => Array
(
[i_status] => pend
[i_title] => 500 HLCoins , 500 HLCoins x8
[i_member] => 1
[i_items] => Array
(
[0] => Array
(
[act] => new
[app] => nexus
[type] => product
[cost] => 0
[tax] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[quantity] => 1
[physical] =>
[shipping] => Array
(
)
[weight] => 0
[itemName] => 500 HLCoins
[itemID] => 3
[cfields] => Array
(
)
[extra] =>
[opt_id] => 0
[associated] =>
[assocBought] =>
[groupRenewals] => 0
[methods] => Array
(
)
[k] => 0
[_tax] => 0
)
[1] => Array
(
[act] => new
[app] => nexus
[type] => product
[cost] => 0
[tax] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[quantity] => 8
[physical] =>
[shipping] => Array
(
)
[weight] => 0
[itemName] => 500 HLCoins
[itemID] => 3
[cfields] => Array
(
)
[opt_id] => 0
[groupRenewals] => 0
[methods] => Array
(
)
[_tax] => 0
)
)
[i_total] => 0
[i_date] => 1347217384
[i_return_uri] =>
[i_paid] => 0
[i_status_extra] => a:1:{s:4:"type";s:4:"zero";}
[i_discount] => 0
[i_temp] =>
[i_ordersteps] => 0
[i_noreminder] => 1
[i_renewal_ids] => Array
(
)
[i_po] =>
[i_notes] =>
[i_shipaddress] =>
[i_id] => 229
)
[takeAction] => 1
)
I've tried a bunch of codes like $invoice->quantity, $invoice[1]->quantity, $this->$invoice->quantity, but none of them seem to display.
It still does not display at all, I tried to print_r and that is the array it gave me.
Seems like all the data is in a private
property. You cannot access it from outside directly.
Read the documentation for the class. It should have some method you can call, like getQuantity()
, that'll get you the data. It depends on how the class was written and how it is supposed to be used.
这篇关于如何检索从PHP对象数组中的项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!