0

I have this array

Array (
[0] => stdClass Object
    (

        [field_commerce_total] => Array
            (
                [0] => Array
                    (
                        [rendered] => Array
                            (
                                [#markup] => 64.00  HRK
                                [#access] => 1
                            )

                        [raw] => Array
                            (
                                [amount] => 6400
                                [currency_code] => HRK
                                [data] => Array
                                    (
                                        [components] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [name] => base_price
                                                        [price] => Array
                                                            (
                                                                [amount] => 5120
                                                                [currency_code] => HRK
                                                                [data] => Array
                                                                    (
                                                                    )

                                                            )

                                                        [included] => 1
                                                    )

                                                [1] => Array
                                                    (
                                                        [name] => tax|sample_french_vat_tax
                                                        [price] => Array
                                                            (
                                                                [amount] => 1280
                                                                [currency_code] => HRK
                                                                [data] => Array
                                                                    (
                                                                        [tax_rate] => Array
                                                                            (
                                                                                [name] => sample_french_vat_tax
                                                                                [display_title] => Croatia VAT (PDV) 25%
                                                                                [description] => 
                                                                                [rate] => 0.25
                                                                                [type] => vat
                                                                                [rules_component] => commerce_tax_rate_sample_french_vat_tax
                                                                                [default_rules_component] => 1
                                                                                [price_component] => tax|sample_french_vat_tax
                                                                                [calculation_callback] => commerce_tax_rate_calculate
                                                                                [module] => commerce_tax_ui
                                                                                [title] => Croatia VAT (PDV) 25%
                                                                                [admin_list] => 1
                                                                            )

                                                                    )

                                                            )

                                                        [included] => 1
                                                    )

                                            )

                                        [include_tax] => sample_french_vat_tax
                                    )

                            )

                    )

            )

    )
)

This array structure is from print_r($results); from drupal view global:PHP. I need to retrieve the value of total amount so it can bee converted to other currency.
I tried to get to the single value like this

echo $results[0]->$field_commerce_total[0]->raw->amount;

It does not work. Andy idea where is my mistake?

munge83
  • 153
  • 1
  • 4
  • 19

1 Answers1

1

Deeper field_commerce_total they are arrays not objects

echo $results[0]->field_commerce_total[0]['raw']['amount'];
splash58
  • 26,043
  • 3
  • 22
  • 34