如何从这个数组中获取[user_id]?
Array
(
[2] => cbpaidSubscription Object
(
[replaces_plan] =>
[replaces_subscription] =>
[subscription_date] => 2009-07-14 12:45:52
[last_renewed_date] => 2009-07-14 12:45:52
[expiry_date] => 2010-07-14 12:45:52
[autorenew_type] => 2
[autorecurring_type] => 2
[regular_recurrings_total] => 0
[regular_recurrings_used] => 1
[previous_expiry_date] =>
[previous_status] => R
[previous_recurrings_used] => 0
[ip_addresses] => 127.0.0.1
[id] => 2
[status] => A
[user_id] => 71
[plan_id] => 1
[parent_plan] => 0
[parent_subscription] => 0
[integrations] =>
[_plan] => cbpaidProductusersubscription Object
(
答案 0 :(得分:3)
我在想......
print $arrayName[2]->user_id;
答案 1 :(得分:2)
如果您可以保证阵列只有一个项目且您知道密钥,那么请使用Jonathan Sampson的解决方案。否则,如果您有一些项目,可以像这样循环,并为每个项目提取用户ID。
foreach ($array as $item) {
$userId = $item->user_id;
//do something with the userId for this item
}