Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing a numeric property in a SimpleXMLElement
    primarykey
    data
    text
    <p>I'm trying to access the number in the below element, but I'm having trouble getting the value out of it. </p> <pre><code>echo $object-&gt;0; //returns Parse error: syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '{' or '$' SimpleXMLElement Object ( [0:public] =&gt; 15810 ) </code></pre> <p>Any ideas on how I can get that value?</p> <p><strong>Update</strong></p> <p>I realize that this is an odd error... I'm using the ebay API to get this value. Even when I do:</p> <pre><code> $zero = 0; $print_r($ruleXml-&gt;HourlyUsage-&gt;$zero); </code></pre> <p>It still shows the same</p> <pre><code>SimpleXMLElement Object ( [0:public] =&gt; 15810 ) </code></pre> <p>I tried <code>{0}</code> as well</p> <p>Here's the output of what I'm working with....</p> <pre><code>[1] =&gt; SimpleXMLElement Object ( [CallName:public] =&gt; AddItem [CountsTowardAggregate:public] =&gt; false [DailyHardLimit:public] =&gt; 100000 [DailySoftLimit:public] =&gt; 100000 [DailyUsage:public] =&gt; 0 [HourlyHardLimit:public] =&gt; 100000 [HourlySoftLimit:public] =&gt; 100000 [HourlyUsage:public] =&gt; 0 [Period:public] =&gt; -1 [PeriodicHardLimit:public] =&gt; 0 [PeriodicSoftLimit:public] =&gt; 0 [PeriodicUsage:public] =&gt; 0 [ModTime:public] =&gt; 2010-05-04T18:06:08.000Z [RuleCurrentStatus:public] =&gt; NotSet [RuleStatus:public] =&gt; RuleOn ) </code></pre> <p>So here's the thing...</p> <pre><code>number_format($ruleXml-&gt;HourlyUsage) //throws the error: number_format() expects parameter 1 to be double, object given $ruleXml-&gt;HourlyUsage //shows the value on the page </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload