3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = ' <?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <OTA_HotelResNotifRS xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd" TimeStamp="2017-04-25T13:54:59+02:00" Version="1.003" EchoToken="58ff3910062c0"> <Success /> <HotelReservations> <HotelReservation> <UniqueID Type="14" ID="24671-CH108B541" /> <ResGlobalInfo> <HotelReservationIDs> <HotelReservationID ResID_Type="14" ResID_Value="24671-CH108B541" /> </HotelReservationIDs> </ResGlobalInfo> </HotelReservation> </HotelReservations> </OTA_HotelResNotifRS> </SOAP-ENV:Body> </SOAP-ENV:Envelope> '; function parseReservationResponseXML($content) { $content = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $content); /* * RateTiger response da xsi eklenince hata aldigimizdan dolayi bu bolum siliniyor. */ $content = str_replace("xsi:schemaLocation='http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd'", '', $content); $requestParams = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $content); try { $xml = new \SimpleXMLElement($requestParams); } catch (\Exception $e) { $xml = null; } $body = (!is_null($xml) && !empty($xml->xpath('//SOAP-ENV:Body')[0])) ? $xml->xpath('//SOAP-ENV:Body')[0] : []; return json_decode(json_encode((array)$body), true); } function getProviderReferenceCode($response) { $response = parseReservationResponseXML($response); if (!empty($response['OTA_HotelResNotifRS']) && !array_key_exists('Success', $response['OTA_HotelResNotifRS'])) { return false; } $providerReferenceCode = (isset($response['OTA_HotelResNotifRS']['HotelReservations']['HotelReservation']['ResGlobalInfo']['HotelReservationIDs']['HotelReservationID']['@attributes']['ResID_Value'])) ? $response['OTA_HotelResNotifRS']['HotelReservations']['HotelReservation']['ResGlobalInfo']['HotelReservationIDs']['HotelReservationID']['@attributes']['ResID_Value'] : false; if (!$providerReferenceCode) { return false; } return $providerReferenceCode; } var_dump(getProviderReferenceCode($xml));
Output for git.master, git.master_jit, rfc.property-hooks
Warning: SimpleXMLElement::__construct(): Entity: line 2: parser error : XML declaration allowed only at the start of the document in /in/qen88 on line 35 Warning: SimpleXMLElement::__construct(): <?xml version="1.0" encoding="UTF-8" ?> in /in/qen88 on line 35 Warning: SimpleXMLElement::__construct(): ^ in /in/qen88 on line 35 Warning: SimpleXMLElement::__construct(): namespace error : xmlns:xsd: 'http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd' is not a valid URI in /in/qen88 on line 35 Warning: SimpleXMLElement::__construct(): tance" xmlns:xsd="http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd" in /in/qen88 on line 35 Warning: SimpleXMLElement::__construct(): ^ in /in/qen88 on line 35 bool(false)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
66.32 ms | 403 KiB | 8 Q