致命错误:不能将 stdClass 用作数组


Fatal error: cannot use stdClass as array

我从一位前同事那里继承了一些代码,由于它最近投入生产,它给我们带来了一些问题。我不是 php 开发人员,所以如果这看起来含糊不清,但已经落到我身上,我深表歉意(不要问!

我们正在调用一个函数getLoan(),以从现有应用程序预填充应用程序表单。这应该返回一个数组,但我收到 stdClass 错误。

$result = getLoan(); //this is the line that is erroring
if (isset($result->GetResult->Debtor->Addresses->Address[0])) $current_address = clone     $result->GetResult->Debtor->Addresses->Address[0];
else $current_address = clone $result->GetResult->Debtor->Addresses->Address;
if ($result === false)
{
  echo("No LID given");
  die;
}
$attr = 'selected';

和功能:

function getLoan() {
//globals
/*
global $client;
global $test;
global $result;
*/
global $thisurl;
if (isset($_GET['LID'])) 
         $pLoanID = $_GET['LID'];
else 
         return false;
$test = array(
        "pLoanID" => $pLoanID,
);
//print_r($Address); //print address object as a test
//send to gateway starts**********
$url = "https://www.blahblah.asmx?WSDL";
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));
try {
    $result = $client->Get($test);
}
catch(Exception $e) {
    //header("Location: http://" . $_SERVER['REMOTE_ADDR'] . "/application-form-new");
    print_r($e);
    exit;
}
$thisurl = "continue-app?LID=" . $pLoanID;
if (isset($result)) return $result;
else return false;
}

如何将函数的返回值作为数组分配给$result?

非常感谢

array = json_decode(json_encode(object),true);