View array data

Asked

Viewed 60 times

0

I need to display this data array and I don’t know how to make the call. I would like to take specific data such as [Postage] => 140.55

[0] => SimpleXMLElement Object
                    (

                        [@attributes] => Array
                            (
                                [ID] => 12
                            )

                        [Pounds] => 2
                        [Ounces] => 0
                        [Machinable] => True
                        [MailType] => Package
                        [Container] => RECTANGULAR
                        [Size] => REGULAR
                        [Width] => 2
                        [Length] => 2
                        [Height] => 2
                        [Girth] => 0
                        [Country] => BRAZIL
                        [Postage] => 140.55
                        [ExtraServices] => SimpleXMLElement Object
                            (
                                [ExtraService] => SimpleXMLElement Object
                                    (
                                        [ServiceID] => 106
                                        [ServiceName] => Insurance
                                        [Available] => True
                                        [Price] => 1.00
                                        [DeclaredValueRequired] => True
                                    )

                            )

                        [ValueOfContents] => 200.00
                        [SvcCommitments] => 1 - 3 business days to many major markets
                        [SvcDescription] => USPS GXG<sup>™</sup> Envelopes
                        [MaxDimensions] => USPS-Produced regular size cardboard envelope (12-1/2" x 9-1/2"), the legal-sized cardboard envelope (15" x 9-1/2") and the GXG Tyvek envelope (15-1/2" x 12-1/2")
                        [MaxWeight] => 70
                    )
  • $var->Postage doesn’t solve?

  • I just answered a question similar to your https://answall.com/questions/334455/como-fa%C3%A7o-para-ler-um-xml-com%C3%A7%C3%A3o-html/334544#334544

  • $var->Postage does not solve, I have tried, actually the structure is bigger than that. It is a return of a query in a US mail api. but it gets too big to run here.

  • Try it like this: $v[0]->Postage

1 answer

-1

Just access the zero position of the array and the attribute.

$var[0]->Postage;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.