您好我想获取attribute_pa_seat_cover的值,所以请帮助我。 目前我是$ values,其中包含以下所有数组列表。目前我正在编写下面的代码,它显示了数组的下面细节。 的print_r($值);
Array
(
[product_id] => 393
[variation_id] => 424
[variation] => Array
(
[pa_seat-cover] => back
)
[quantity] => 4
[data] => WC_Product_Variation Object
(
[variation_id] => 424
[parent] => WC_Product_Variable Object
(
[children] =>
[total_stock] =>
[id] => 393
[post] => WP_Post Object
(
[ID] => 393
[post_author] => 1
[post_date] => 2014-02-02 01:13:10
[post_date_gmt] => 2014-02-02 01:13:10
[post_content] => Please contact in store for information and ordering
[post_title] => POSITANO
[post_excerpt] =>
[post_status] => publish
[comment_status] => open
[ping_status] => closed
[post_password] =>
[post_name] => positano
[to_ping] =>
[pinged] =>
[post_modified] => 2014-02-13 13:44:56
[post_modified_gmt] => 2014-02-13 13:44:56
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://localhost/thecanvas?post_type=product&p=393
[menu_order] => 0
[post_type] => product
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
[format_content] =>
)
[product_type] => variable
)
[variation_data] => Array
(
[attribute_pa_seat-cover] => back
)
答案 0 :(得分:1)
你可以尝试这作为最后一击吗?
您的[data] => WC_Product_Variation Object
是一个对象,因此应使用->
运算符进行访问,其他运算符只是普通数组。
print $values['data']->variation_data['attribute_pa_seat-cover'];