美好的一天。希望有人可以帮助我解决我的问题,获取实际的String值而不是id。
<Pull_ListSpecProp_RS>
<Property>
<Amenities>
<Amenity Count="1">2</Amenity>
<Amenity Count="1">4</Amenity>
<Amenity Count="1">6</Amenity>
<Amenity Count="2">19</Amenity>
<Amenity Count="1">74</Amenity>
<Amenity Count="1">115</Amenity>
<Amenity Count="1">124</Amenity>
<Amenity Count="1">125</Amenity>
<Amenity Count="1">140</Amenity>
<Amenity Count="1">174</Amenity>
<Amenity Count="1">180</Amenity>
<Amenity Count="1">187</Amenity>
<Amenity Count="1">395</Amenity>
<Amenity Count="1">589</Amenity>
<Amenity Count="1">792</Amenity>
<Amenity Count="1">798</Amenity>
</Amenities>
<Property>
</Pull_ListSpecProp_RS>
**
<Pull_ListAmenities_RS>
<Amenities>
<Amenity AmenityID="2">Cookware & Kitchen Utensils</Amenity>
<Amenity AmenityID="3">Crockery & Cutlery</Amenity>
<Amenity AmenityID="4">Iron & Ironing Board</Amenity>
<Amenity AmenityID="5">Drying Rack</Amenity>
<Amenity AmenityID="6">Hair Dryer</Amenity>
<Amenity AmenityID="7">Bed Linen & Towels</Amenity>
<Amenity AmenityID="8">Toiletries</Amenity>
</Amenities>
</Pull_ListAmenities_RS>
if(Amenity == AmenityID)如果为True,我希望返回值为第二个礼仪响应的字符串值。
示例Amenity = 2且AmenityID = 2,返回值为
if(Amenity == AmenityID){
echo Amenity;
}
//Output Cookware & Kitchen Utensils
这是我目前的代码
foreach($Pull_ListSpecProp_RQ->Property->Amenities->Amenity as $AmenityID){ //This foreach is to get all the available Amenity of a specific/selected room
foreach ($Pull_ListAmenities_RQ->Amenities->Amenity as $Amenity) { //This for each is to get all the List of amenities.
//echo "ID: ".$Amenity['AmenityID']."<br/>";
if ($AmenityID == $Amenity['AmenityID']) {
echo "ID: ".$Amenity."<br/>";
}
}
}
希望我的问题和解释是可以理解的。对不起我的这个愚蠢的问题。我不是一个优秀的程序员,但是:)。
答案 0 :(得分:3)
变量$AmenityID
和$Amenity
的类型为SimpleXMLElement。
这些方法__toString将返回字符串内容。
也许您可以将$AmenityID
的字符串内容与AmenityID
的{{1}}属性进行比较。
例如:
$Amenity