tags:

views:

36

answers:

2

How would I access the 14.95 here?

$object->{0} or $object[0] doesn't work

   SimpleXMLElement Object
    (
        [@attributes] => Array
            (
                [currencyID] => USD
            )

        [0] => 14.95
    )

Interesting... If I do (int)$object->{0} it works....

A: 

Its bad practice to have numbers as properties of an object. Wouldn't a named property be easier to maintain?

Edit: I previously thought this wasn't actually possible however it looks like it is and instead leaves the code just a little ambiguous.

D Roddis
This happens when I pull from the eBay API, so I don't have a choice.
Webnet
A: 

Force it to be an integer: (int)$object->{0}

Webnet