0
我試圖通過SOAP響應的ROOMPRICE結果進行排序:PHP:SOAP響應排序
stdClass Object (
[GetHotelsResult] => stdClass Object (
[SEARCH_RESPONSE] => Array (
[0] => stdClass Object (
[HOTELNAME] => Hotel1
[ROOMNAME] => Room2
[ROOMPRICE] => 144.50
)
[1] => stdClass Object (
[HOTELNAME] => Hotel1
[ROOMNAME] => Room1
[ROOMPRICE] => 231.10
)
[2] => stdClass Object (
[HOTELNAME] => Hotel1
[ROOMNAME] => Room3
[ROOMPRICE] => 94.00
)
)
)
);
我做了很多的解決方案,但他們沒有工作...
實際代碼:
$sClient = new SoapClient($wsdl, array('trace' => 1));
$response = $sClient->GetHotels($data);
$ghdata = $sClient->__getLastResponse();
$doc = new DOMDocument();
$doc->loadXML($ghdata);
$x = $doc->documentElement;
$rooms = $x->getElementsByTagName("SEARCH_RESPONSE");
foreach($rooms as $SEARCH_RESPONSE)
{ // show results
好像有錯誤或你的迴應錯字:'SEARCH_RESPONSE'陣列不能有每個記錄都帶有'0'索引。 –