我在wp / woocommerce中有这个数组:
Array ( [0] => Array( [variation_id] => 18919 [variation_is_visible] => 1 [is_purchasable] => 1 [attributes] => Array( [attribute_seleccionar-opcion] => precio-nino) [image_src] => [image_link] => [image_title] => [image_alt] => [price_html] => $380,00 [availability_html] => [sku] => [weight] => kg [dimensions] => [min_qty] => 1 [max_qty] => [backorders_allowed] => [is_in_stock] => 1 [is_downloadable] => [is_virtual] => 1 [is_sold_individually] => no) [1] => Array( [variation_id] => 18921 [variation_is_visible] => 1 [is_purchasable] => 1 [attributes] => Array( [attribute_seleccionar-opcion] => precio-adulto) [image_src] => [image_link] => [image_title] => [image_alt] => [price_html] => $399,00 [availability_html] => [sku] => precio adulto [weight] => 200 kg [dimensions] => 1 x 2 x 3 cm [min_qty] => 1 [max_qty] => [backorders_allowed] => [is_in_stock] => 1 [is_downloadable] => [is_virtual] => 1 [is_sold_individually] => no) )
我需要让我回到这个值'variation_id'并显示这个(get_post_meta很多,因为'variation_id'有数组):
echo get_post_meta(18919, 'precio_normal_euro', true ); echo get_post_meta(18921, 'precio_normal_euro', true );
谢谢你“
答案 0 :(得分:1)
我认为这应该有所帮助。
$key = 'variation_id';
foreach ($myArray as $arr) {
if (isset($arr[$key])) {
echo get_post_meta($arr[$key], 'precio_normal_euro', true);
}
}
答案 1 :(得分:0)
好主意,谢谢......我已经解决了这个问题:
for($i = 0; $i < count($available_variations); ++$i) {
$value_ = $available_variations[$i]['variation_id'];
echo 'precio normal €:'.get_post_meta($value_, 'precio_normal_euro', true );
echo 'precio rebajado €:'.get_post_meta($value_, 'precio_rebajado_euro', true );
}
显示:precio normal €:5precio rebajado €:55precio normal €:100precio rebajado €:120