访问Smarty数组中的变量

时间:2010-05-12 11:54:51

标签: multidimensional-array smarty

我正在尝试访问smarty数组中的变量。该数组称为product,包含大量值。数组的print_r转储如下所示

Array
(
    [0] => Array
        (
            [itemid] => 4
            [productid] => 31
            [productcode] => 1658303
            [product] => ENERGIZER 628504 COMP RECHARGABLE TORCH
            [provider] => master
            [distribution] => 
            [weight] => 0.00
            [list_price] => 29.80
            [descr] => Torches
            [fulldescr] => Energizer Rechargeable Emergency Torch Complete With Krypton Bulb
            [avail] => 6
            [rating] => 2
            [forsale] => Y
            [add_date] => 0
            [views_stats] => 1
            [sales_stats] => 0
            [del_stats] => 0
            [shipping_freight] => 0.00
            [free_shipping] => N
            [discount_avail] => Y
            [min_amount] => 1
            [length] => 0.00
            [width] => 0.00
            [height] => 0.00
            [low_avail_limit] => 10
            [free_tax] => N
            [product_type] => N
            [manufacturerid] => 0
            [return_time] => 0
            [keywords] =>  
            [meta_description] => 
            [meta_keywords] => 
            [small_item] => N
            [separate_box] => N
            [items_per_box] => 1
            [title_tag] => 
            [orderid] => 2
            [price] => 11.96
            [amount] => 2
            [product_options] => 
            [extra_data] => Array
                (
                    [product_options] => 
                    [taxes] => Array
                        (
                        )

                    [display] => Array
                        (
                            [price] => 11.96
                            [discounted_price] => 23.92
                            [subtotal] => 23.92
                        )

                )

            [is_deleted] => 
            [returns] => 
            [extra_fields] => Array
                (
                    [0] => Array
                        (
                            [fieldid] => 1
                            [provider] => master
                            [field] => ESW Carbon Points
                            [value] => 50
                            [active] => Y
                            [orderby] => 1
                            [service_name] => SERVICE_NAME01
                            [productid] => 31
                        )

                )

            [display_price] => 11.96
            [display_discounted_price] => 23.92
            [display_subtotal] => 23.92
            [product_options_txt] => 
            [ordered_price] => 11.96
            [original_price] => 11.96
            [price_deducted_tax] => Y
        )

)

我想访问额外字段数组中的“value”字段,但我不明白它的语法是什么。

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:1)

{$var[0].extra_fields[0].value}

答案 1 :(得分:0)

{$var.0.extra_fields.0.value}