我有一个数组,它在对象中返回更多数组和其他数据。如何定位这些对象内的数据?var_export 中对象前面的名称是您可以引用的实际名称吗?
在下面的示例代码中:我认为 var_dump($product->WC_Product_Variation['variation_id']); 将返回“278”,而不是它给出一个 NULL。关于定位对象内的内容,我做错了什么?
这是我的 $product 的 var_export:
array (
'product_id' => 259,
'variation_id' => 278,
'variation' =>
array (
'pa_afmetingen-liggend' => 'm011',
),
'quantity' => 1,
'data' =>
WC_Product_Variation::__set_state(array(
'variation_id' => 278,
'parent' =>
WC_Product_Variable::__set_state(array(
'children' => NULL,
'total_stock' => NULL,
'id' => 259,
'post' =>
WP_Post::__set_state(array(
'ID' => 259,
'post_author' => '1',
'post_date' => '2013-06-05 13:22:26',
'post_date_gmt' => '2013-06-05 13:22:26', 'post_content' => 'liggend', 'post_title' => 'Wit liggend', 'post_excerpt' => '', 'post_status' => 'publish', 'comment_status' => 'open', 'ping_status' => 'closed', 'post_password' => '', 'post_name' => 'wit-liggend', 'to_ping' => '', 'pinged' => '', 'post_modified' => '2013-06-27 09:24:08', 'post_modified_gmt' => '2013-06-27 09:24:08', 'post_content_filtered' => '', 'post_parent' => 0, 'guid' => 'http://www.***.nl/?post_type=productp=259',
'menu_order' => 0,
'post_type' => 'product',
'post_mime_type' => '',
'comment_count' => '0',
'filter' => 'raw',
)),
'product_type' => 'variable',
)),
'variation_data' =>
array (
'attribute_pa_afmetingen-liggend' => 'm011', ), 'variation_has_length' => false, 'variation_has_width' => false, 'variation_has_height' => false, 'variation_has_weight' => false, 'variation_has_stock' => false, 'variation_has_sku' => false, 'variation_shipping_class' => false, 'variation_shipping_class_id' => false, 'variation_has_tax_class' => true, 'id' => 259, 'post' => WP_Post::__set_state(array( 'ID' => 259, 'post_author' => '1', 'post_date' => '2013-06-05 13:22:26', 'post_date_gmt' => '2013-06-05 13:22:26', 'post_content' => 'liggend', 'post_title' => 'Wit liggend', 'post_excerpt' => '', 'post_status' => 'publish', 'comment_status' => 'open', 'ping_status' => 'closed', 'post_password' => '', 'post_name' => 'wit-liggend', 'to_ping' => '', 'pinged' => '', 'post_modified' => '2013-06-27 09:24:08', 'post_modified_gmt' => '2013-06-27 09:24:08', 'post_content_filtered' => '', 'post_parent' => 0, 'guid' => 'http://www.***.nl/?post_type=productp=259',
'menu_order' => 0,
'post_type' => 'product',
'post_mime_type' => '',
'comment_count' => '0',
'filter' => 'raw',
)),
'product_type' => 'variation',
'product_custom_fields' =>
array (
'_sku' =>
array (
0 => '',
),
'_weight' =>
array (
0 => '',
),
'_length' =>
array (
0 => '',
),
'_width' =>
array (
0 => '',
),
'_height' =>
array (
0 => '',
),
'_stock' =>
array (
0 => '',
),
'_thumbnail_id' =>
array (
0 => '0',
),
'_virtual' =>
array (
0 => 'no',
),
'_downloadable' =>
array (
0 => 'no',
),
'_regular_price' =>
array (
0 => '83',
),
'_sale_price' =>
array (
0 => '',
),
'_sale_price_dates_from' =>
array (
0 => '',
),
'_sale_price_dates_to' =>
array (
0 => '',
),
'_price' =>
array (
0 => '83',
),
'_tax_class' =>
array (
0 => '',
),
'_download_limit' =>
array (
0 => '',
),
'_download_expiry' =>
array (
0 => '',
),
'_file_paths' =>
array (
0 => '',
),
'attribute_pa_afmetingen-liggend' =>
array (
0 => 'm011',
),
),
'downloadable' => 'no',
'virtual' => 'no',
'tax_class' => '',
'sale_price_dates_from' => '',
'price' => '83',
'regular_price' => '83',
'sale_price' => '',
'total_stock' => 0,
)),
'time' => 'http://www.***.nl/wp-content/themes/***/uploads/resized_1372667650.jpg',
'thumbnail' => 'http://www.***.nl/wp-content/themes/***/uploads/resizedThumbnail_1372667650.jpg',
'line_total' => 83,
'line_tax' => 0,
'line_subtotal' => 83,
'line_subtotal_tax' => 0,
)