Jump to content

stdClass to array


soycharliente

Recommended Posts

I'm using a SoapClient to talk to another server and send/receive information. When making a web service call to get some information, it is returned formated like this:

 

stdClass Object ( [information] => <xml>......</xml> )

 

I am getting an error when I simply try to grab the information via a SimpleXMLElement. The error says:

Fatal error: Cannot use object of type stdClass as array in /file.php on line 12

 

How can I convert the format I'm getting back so that I can walk the XML tree? I hope this makes sense.

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/205861-stdclass-to-array/
Share on other sites

  • 1 year later...

Interesting,

What happened if the answer of the WS has this structure:

 

object(stdClass)[2]
  public 'generarCFDIPruebaResult' => 
    object(stdClass)[3]
      public 'string' => 
        array
          0 => string 'True' (length=4)
          1 => string '' (length=0)
          2 => string 'Z' (length=1)
          3 => string '<xml>...<xml>

 

I can not use:

 

 $response = object->3;

 

What can I do?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/205861-stdclass-to-array/#findComment-1238868
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.