There is an array

UnboundedElementsIterator Object ( [xmlList:protected] => SimpleXMLElement Object ( [@attributes] => Array ( [Sign] => смн [Code] => TJS ) [0] => 43 ) [elementsType:protected] => Array ( [type] => complexType [name] => OtapiMoney ) [position:UnboundedElementsIterator:private] => 0 ) $res = $item->GetMoney(); 

I want to display the value 43 , but it does not work. I do this:

 print_r($res[0]); 
  • 2
    it is not an array, but an object, and with private properties. You need to look at the methods of the UnboundedElementsIterator class and use them to get the necessary data. - Marsel Arduanov
  • @MarselArduanov, thanks for finding there is such a construct: public function __construct($xmlList, $elementsType){ $this->xmlList = $xmlList; $this->elementsType = $elementsType; $this->position = 0; } public function __construct($xmlList, $elementsType){ $this->xmlList = $xmlList; $this->elementsType = $elementsType; $this->position = 0; } public function __construct($xmlList, $elementsType){ $this->xmlList = $xmlList; $this->elementsType = $elementsType; $this->position = 0; } how to transfer the object correctly if the data is stored here $res = $item->GetMoney() - mega94
  • one
    @ mega94, this code is not enough - Marsel Arduanov
  • one
    var_dump(get_class_methods(get_class($res))) ? - E_p

1 answer 1

Something tells me that the target is an iterator . And if so, then to get the desired value, it is enough to execute the following code:

 $res->rewind(); $value = $res->current(); 

More information about the methods \ Iterator :: current and \ Iterator :: rewind can be read in the office. PHP documentation.

  • Ohh, I just realized about it, I looked at what was in current() using get_class_methods(get_class($res)) and asString did this: $res = $item->GetMoney()->current()->asString() meaning was derived thanks a lot - mega94