我正在使用简单的PHP脚本,该脚本根据XML中的数据显示故障。它的作用是:将没有崩溃的图像放到站点(在div类外部),然后我只检查XML,如果值=&#34; Y&#34;它应该在它上面显示图像。问题是我永远不会显示&#34;前面&#34;图像,而不是我总是得到&#34;,&#34;而不是<div class = "front">
有人可以告诉我什么错了吗?
$first_damage_zone = true;
//loop through the damage zones as key value pairs
echo '<div class="outer">' ; //show blanked car image
foreach ( $claim ['damage'] ['general'] as $key => $value ) {
if ($value == 'Y') {
if ($first_damage_zone) {
}
switch ($key) {
case 'roof' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_ROOF;
echo '<div class="roof"></div>';
break;
case 'underbody' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_UNDERBODY;
break;
case 'front' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_FRONT;
echo '<div class="front"></div>';
break;
case 'front-left' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_FRONTLEFT;
echo '<div class="front-left"></div>';
break;
case 'front-right' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_FRONTRIGHT;
echo '<div class="front-right"></div>';
break;
case 'rear' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_REAR;
echo '<div class="rear"></div>';
break;
case 'rear-left' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_REARLEFT;
echo '<div class="rear-left"></div>';
break;
case 'rear-right' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_REARRIGHT;
echo '<div class="rear-right"></div>';
break;
case 'mechanical' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_MECHANICAL;
break;
case 'interior' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_INTERIOR;
break;
case 'center' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_CENTER;
echo '<div class="roof"></div>';
break;
case 'side-left' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_SIDELEFT;
echo '<div class="car-left"></div>';
break;
case 'side-right' :
@$key = $_VIN_QUERY_DAMAGED_ZONES_SIDERIGHT;
echo '<div class="car-right"></div>';
break;
echo '<div>';
}
if ($first_damage_zone) {
print $key;
$first_damage_zone = false;
} else {
print ', ' . $key;
}
}
}
P.S。我确信在XML中有标签前端,我确信它也有值Y.所以这让我很困惑:(
XML:
-
<damage>-
<general>
<front>Y</front>
<front-left>Y</front-left>
<front-right>N</front-right>
<interior>N</interior>
<mechanical>N</mechanical>
<rear>N</rear>
<rear-left>N</rear-left>
<rear-right>N</rear-right>
<roof>N</roof>
<side-left>Y</side-left>
<side-right>N</side-right>
<underbody>N</underbody>
</general>