我从SOAP客户端获得了以下参数,其中所有参数都具有正确显示的单个值,并且只有SerialEquipment参数是一个数组且具有多个值且无法显示此参数的结果。它只是作为一个Array回应。我正在尝试很长一段时间但无法显示SerialEquipment的结果。
使用var_dump的数组结果:
array (size=4)
'Emission Badge' => int 4
'Car Tax' => float 146
'Tax Type' => string 'D' (length=1)
'SerialEquipment' =>
array (size=41)
0 =>
object(stdClass)[6]
public 'Code' => int 204093
public 'Desc_Short' => string 'Ablagefach mittig in Gepäckraumtrennwand;ESACO_UG(122)' (length=55)
public 'Desc_Long' => string 'Ablagefach mittig in Gepäckraumtrennwand inkl. verschiebbarem Haltenetz' (length=72)
1 =>
object(stdClass)[8]
public 'Code' => int 160452
public 'Desc_Short' => string 'Airbag für Fahrer und Beifahrer, 2-stufi;ESACO_UG(103)' (length=55)
public 'Desc_Long' => string 'Airbag für Fahrer und Beifahrer 2-stufig' (length=41)
代码:
function getVehicleValuation()
{
$result = $client->getVehicleValuation($params);
$return = array(
'Emission Badge' => $result->vehicle->Emission_Badge,
'Car Tax' => $result->vehicle->Car_Tax,
'Tax Type' => $result->vehicle->Tax_Type,
'SerialEquipment' => $result->vehicle->SerialEquipment
);
return $return;
}
在此处显示结果:
if($parameter['aktion'] == 'getVehicle')
{
$returned_array=getVehicleValuation();
foreach($returned_array as $objects)
{
foreach($objects as $key => $obj)
{
echo "key.: " . $key . "<br>";
echo $obj->Code . "<br>";
echo $obj->Desc_Short . "<br>";
echo $obj->Desc_Long . "<br>";
}
}
}
答案 0 :(得分:0)
检查php documentation regarding arrays以及如何使用它们。
$vehicle = getVehicleValuation();
echo $vehicle['Emission Badge'] . ', ' . $vehicle['Car Tax'] . ', ' . $vehicle['Tax Type'] . ', ' . $vehicle['SerialEquipment'] . '<\ br>';