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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.