2012-08-16 16 views
-3

我有數組從會議上獲得,這是print_r的陣列的PHP接取多數組對象

print_r($_SESSION['wpsc_cart']); 



wpsc_cart Object ([delivery_country] => AU [selected_country] => AU [delivery_region] => [selected_region] => [selected_shipping_method] => [selected_shipping_option] => [selected_shipping_amount] => [coupon] => [tax_percentage] => 0 [unique_id] => 98b4abe821cda949c0a6feedcd51487134765124 [errors] => Array () [total_tax] => [base_shipping] => [total_item_shipping] => [total_shipping] => [subtotal] => 105 [total_price] => [uses_shipping] => [is_incomplete] => 1 [cart_items] => Array ([0] => wpsc_cart_item Object ([cart] => wpsc_cart Object *RECURSION* [product_id] => 1675 [variation_values] => [product_variations] => [variation_data] => [quantity] => 1 [provided_price] => [product_name] => Gift Card [category_list] => Array ([0] => 30) [category_id_list] => Array ([0] => 13) [unit_price] => 30 [total_price] => 30 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://www.activefeet.com.au/products-page/30/gift-card [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ([0] => Array ([wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [weight] => 0 [weight_unit] => pound [dimensions] => Array ([height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in) [shipping] => Array ([local] => 5 [international] => 5) [no_shipping] => 1 [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [unpublish_when_none_left] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ([quantity] => Array () [table_price] => Array ()) [google_prohibited] => 0)) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 0 [has_limited_stock] => [file_id] => [is_downloadable] =>) [1] => wpsc_cart_item Object ([cart] => wpsc_cart Object *RECURSION* [product_id] => 1679 [variation_values] => [product_variations] => [variation_data] => [quantity] => 1 [provided_price] => [product_name] => Gift Card [category_list] => Array ([0] => 76) [category_id_list] => Array ([0] => 15) [unit_price] => 75 [total_price] => 75 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://www.activefeet.com.au/products-page/76/gift-card-3 [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ([0] => Array ([wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [weight] => 0 [weight_unit] => pound [dimensions] => Array ([height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in) [shipping] => Array ([local] => 0 [international] => 0) [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [unpublish_when_none_left] => 0 [no_shipping] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ([quantity] => Array () [table_price] => Array ()) [google_prohibited] => 0)) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 1 [has_limited_stock] => [file_id] => [is_downloadable] =>)) [cart_item] => wpsc_cart_item Object ([cart] => wpsc_cart Object *RECURSION* [product_id] => 1675 [variation_values] => [product_variations] => [variation_data] => [quantity] => 1 [provided_price] => [product_name] => Gift Card [category_list] => Array ([0] => 30) [category_id_list] => Array ([0] => 13) [unit_price] => 30 [total_price] => 30 [taxable_price] => 0 [tax] => 0 [weight] => 0 [shipping] => 0 [sku] => [product_url] => http://www.activefeet.com.au/products-page/30/gift-card [image_id] => [thumbnail_image] => [custom_tax_rate] => [meta] => Array ([0] => Array ([wpec_taxes_taxable_amount] => [external_link] => [external_link_text] => [external_link_target] => [weight] => 0 [weight_unit] => pound [dimensions] => Array ([height] => 0 [height_unit] => in [width] => 0 [width_unit] => in [length] => 0 [length_unit] => in) [shipping] => Array ([local] => 5 [international] => 5) [no_shipping] => 1 [merchant_notes] => [engraved] => 0 [can_have_uploaded_image] => 0 [enable_comments] => [unpublish_when_none_left] => 0 [quantity_limited] => 0 [special] => 0 [display_weight_as] => pound [table_rate_price] => Array ([quantity] => Array () [table_price] => Array ()) [google_prohibited] => 0)) [is_donation] => 0 [apply_tax] => 1 [priceandstock_id] => 0 [custom_message] => [custom_file] => [comment] => [time_requested] => [file_data] => [is_customisable] => [stock] => [uses_shipping] => 0 [has_limited_stock] => [file_id] => [is_downloadable] =>) [cart_item_count] => 2 [current_cart_item] => -1 [in_the_loop] => [shipping_methods] => [shipping_method] => [shipping_method_count] => 1 [current_shipping_method] => -1 [in_the_method_loop] => [shipping_quotes] => [shipping_quote] => [shipping_quote_count] => 0 [current_shipping_quote] => -1 [in_the_quote_loop] => [coupons_name] => [coupons_amount] => 0 [shipping_option] =>) 

我需要從這個數組

[no_shipping] => 1 

[no_shipping] => 0 

得到物品使用一些foreach或..我不知道這個,請幫助我.. 謝謝

+1

我沒有看到數組,而是一個對象。請查看「wpsc_cart」類來了解如何訪問這些成員。 – feeela 2012-08-16 07:36:35

+0

print_r($ _ SESSION ['wpsc_cart']); 返回此 – 2012-08-16 07:37:36

+0

是的,它的確如此。而'$ _SESSION'實際上是一個數組。但'print_r()'也可以調試/轉儲對象的內容 - 它會告訴你它是否存在:'wpsc_cart Object ...' – feeela 2012-08-16 07:39:17

回答

0

我直接使用的對象,它很容易比轉換t會話到對象

foreach($wpsc_cart->cart_items as $i => $Item) {  
      $cv=$Item->meta; 

      foreach($cv as $vc=>$it){   
       echo $it['no_shipping']; 
    } 
}