views:

95

answers:

2

how can i get [user_id] from this array?

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  
            (
+3  A: 

I'm thinking...

print $arrayName[2]->user_id;
Jonathan Sampson
+1  A: 

If you can guarantee that the array only has one item and you know the key, then go with Jonathan Sampson's solution. Otherwise if you have a few items you can loop over it like this and extract the userid for each one.

foreach ($array as $item) {
    $userId = $item->user_id;
    //do something with the userId for this item
}
Tom Haigh