note 85819 modified in function.soap-soapclient-soapcall by danbrown

From: Date: Fri, 19 Sep 2008 14:19:48 +0000
Subject: note 85819 modified in function.soap-soapclient-soapcall by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144549@lists.php.net to get a copy of this message
When I try to convert result to array I get "Cannot use object of type stdClass as array ..." so I use next: <?php function toArray($obj){ $return=array(); if (is_array($obj)) { $keys=array_keys($obj); } elseif (is_object($obj)) { $keys=array_keys(get_object_vars($obj)); } else {return $obj;} foreach ($keys as $key) { $value=$obj->$key; if (is_array($obj)) { $return[$key]=toArray($obj[$key]); } else { $return[$key]=toArray($obj->$key); } } return $return; } ?> --was-- When I try to convert result to array I get "Cannot use object of type stdClass as array ..." so I use next: function toArray($obj){ $return=array(); if (is_array($obj)) { $keys=array_keys($obj); } elseif (is_object($obj)) { $keys=array_keys(get_object_vars($obj)); } else {return $obj;} foreach ($keys as $key) { $value=$obj->$key; if (is_array($obj)) { $return[$key]=toArray($obj[$key]); } else { $return[$key]=toArray($obj->$key); } } return $return; } http://php.net/manual/en/function.soap-soapclient-soapcall.php

« previous php.notes (#144549) next »