2

I'm trying to access a variable in a smarty array. The array is called product and contains loads of values. A print_r dump of the array is shown below

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
        )

)

I want to access the "value" field within the extra fields array but I don't understand what the syntax is to get to it.

Any help greatly appreciated.

2 Answers 2

1
{$var[0].extra_fields[0].value}
Sign up to request clarification or add additional context in comments.

1 Comment

What you've written makes perfect sense to me and I'm sure it would work normally but it doesn't for me. I think it is to do with the way the application I'm using processes the smarty variables between where I did the print_r and where I'm trying to output the variable. Anyway, your suggested solution did put me on the right track to get things working, I was just trying to approach it in a way too complicated manner. So thanks!
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.