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));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qen88
function name:  (null)
number of ops:  8
compiled vars:  !0 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0A%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22+%3F%3E%0A%3CSOAP-ENV%3AEnvelope+xmlns%3ASOAP-ENV%3D%22http%3A%2F%2Fschemas.xmlsoap.org%2Fsoap%2Fenvelope%2F%22%3E%0A++++%3CSOAP-ENV%3ABody%3E%0A++++++++%3COTA_HotelResNotifRS+xmlns%3D%22http%3A%2F%2Fwww.opentravel.org%2FOTA%2F2003%2F05%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22+xmlns%3Axsd%3D%22http%3A%2F%2Fwww.opentravel.org%2FOTA%2F2003%2F05+OTA_HotelResNotifRQ.xsd%22+TimeStamp%3D%222017-04-25T13%3A54%3A59%2B02%3A00%22+Version%3D%221.003%22+EchoToken%3D%2258ff3910062c0%22%3E%0A++++++++++++%3CSuccess+%2F%3E%0A++++++++++++%3CHotelReservations%3E%0A++++++++++++++++%3CHotelReservation%3E%0A++++++++++++++++++++%3CUniqueID+Type%3D%2214%22+ID%3D%2224671-CH108B541%22+%2F%3E%0A++++++++++++++++++++%3CResGlobalInfo%3E%0A++++++++++++++++++++++++%3CHotelReservationIDs%3E%0A++++++++++++++++++++++++++++%3CHotelReservationID+ResID_Type%3D%2214%22+ResID_Value%3D%2224671-CH108B541%22+%2F%3E%0A++++++++++++++++++++++++%3C%2FHotelReservationIDs%3E%0A++++++++++++++++++++%3C%2FResGlobalInfo%3E%0A++++++++++++++++%3C%2FHotelReservation%3E%0A++++++++++++%3C%2FHotelReservations%3E%0A++++++++%3C%2FOTA_HotelResNotifRS%3E%0A++++%3C%2FSOAP-ENV%3ABody%3E%0A%3C%2FSOAP-ENV%3AEnvelope%3E%0A'
   64     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'getproviderreferencecode'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function parsereservationresponsexml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 35
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 42
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Found catch point at position: 24
Branch analysis from position: 24
2 jumps found. (Code = 107) Position 1 = 25, Position 2 = -2
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 35
Branch analysis from position: 29
Branch analysis from position: 35
filename:       /in/qen88
function name:  parseReservationResponseXML
number of ops:  54
compiled vars:  !0 = $content, !1 = $requestParams, !2 = $xml, !3 = $e, !4 = $body
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !0, $5
   30     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 'xsi%3AschemaLocation%3D%27http%3A%2F%2Fwww.opentravel.org%2FOTA%2F2003%2F05+OTA_HotelResNotifRQ.xsd%27'
          9        SEND_VAL                                                 ''
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !0, $7
   32    13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAL                                                 '%2F%28%3C%5C%2F%3F%29%28%5Cw%2B%29%3A%28%5B%5E%3E%5D%2A%3E%29%2F'
         15        SEND_VAL                                                 '%241%242%243'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $9      
         18        ASSIGN                                                   !1, $9
   35    19        NEW                                              $11     'SimpleXMLElement'
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !2, $11
         23      > JMP                                                      ->26
   36    24  E > > CATCH                                       last         'Exception'
   37    25    >   ASSIGN                                                   !2, null
   40    26    >   TYPE_CHECK                                    2  ~15     !2
         27        BOOL_NOT                                         ~16     ~15
         28      > JMPZ_EX                                          ~16     ~16, ->35
         29    >   INIT_METHOD_CALL                                         !2, 'xpath'
         30        SEND_VAL_EX                                              '%2F%2FSOAP-ENV%3ABody'
         31        DO_FCALL                                      0  $17     
         32        ISSET_ISEMPTY_DIM_OBJ                         1  ~18     $17, 0
         33        BOOL_NOT                                         ~19     ~18
         34        BOOL                                             ~16     ~19
         35    > > JMPZ                                                     ~16, ->42
         36    >   INIT_METHOD_CALL                                         !2, 'xpath'
         37        SEND_VAL_EX                                              '%2F%2FSOAP-ENV%3ABody'
         38        DO_FCALL                                      0  $20     
         39        FETCH_DIM_R                                      ~21     $20, 0
         40        QM_ASSIGN                                        ~22     ~21
         41      > JMP                                                      ->43
         42    >   QM_ASSIGN                                        ~22     <array>
         43    >   ASSIGN                                                   !4, ~22
   42    44        INIT_FCALL                                               'json_decode'
         45        INIT_FCALL                                               'json_encode'
         46        CAST                                          7  ~24     !4
         47        SEND_VAL                                                 ~24
         48        DO_ICALL                                         $25     
         49        SEND_VAR                                                 $25
         50        SEND_VAL                                                 <true>
         51        DO_ICALL                                         $26     
         52      > RETURN                                                   $26
   43    53*     > RETURN                                                   null

End of function parsereservationresponsexml

Function getproviderreferencecode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 33
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
Branch analysis from position: 38
Branch analysis from position: 12
filename:       /in/qen88
function name:  getProviderReferenceCode
number of ops:  40
compiled vars:  !0 = $response, !1 = $providerReferenceCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   47     1        INIT_FCALL                                               'parsereservationresponsexml'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   49     5        ISSET_ISEMPTY_DIM_OBJ                         1  ~4      !0, 'OTA_HotelResNotifRS'
          6        BOOL_NOT                                         ~5      ~4
          7      > JMPZ_EX                                          ~5      ~5, ->12
          8    >   FETCH_DIM_R                                      ~6      !0, 'OTA_HotelResNotifRS'
          9        ARRAY_KEY_EXISTS                                 ~7      'Success', ~6
         10        BOOL_NOT                                         ~8      ~7
         11        BOOL                                             ~5      ~8
         12    > > JMPZ                                                     ~5, ->14
   50    13    > > RETURN                                                   <false>
   53    14    >   FETCH_DIM_IS                                     ~9      !0, 'OTA_HotelResNotifRS'
         15        FETCH_DIM_IS                                     ~10     ~9, 'HotelReservations'
         16        FETCH_DIM_IS                                     ~11     ~10, 'HotelReservation'
         17        FETCH_DIM_IS                                     ~12     ~11, 'ResGlobalInfo'
         18        FETCH_DIM_IS                                     ~13     ~12, 'HotelReservationIDs'
         19        FETCH_DIM_IS                                     ~14     ~13, 'HotelReservationID'
         20        FETCH_DIM_IS                                     ~15     ~14, '%40attributes'
         21        ISSET_ISEMPTY_DIM_OBJ                         0          ~15, 'ResID_Value'
         22      > JMPZ                                                     ~16, ->33
   54    23    >   FETCH_DIM_R                                      ~17     !0, 'OTA_HotelResNotifRS'
         24        FETCH_DIM_R                                      ~18     ~17, 'HotelReservations'
         25        FETCH_DIM_R                                      ~19     ~18, 'HotelReservation'
         26        FETCH_DIM_R                                      ~20     ~19, 'ResGlobalInfo'
         27        FETCH_DIM_R                                      ~21     ~20, 'HotelReservationIDs'
         28        FETCH_DIM_R                                      ~22     ~21, 'HotelReservationID'
         29        FETCH_DIM_R                                      ~23     ~22, '%40attributes'
         30        FETCH_DIM_R                                      ~24     ~23, 'ResID_Value'
         31        QM_ASSIGN                                        ~25     ~24
         32      > JMP                                                      ->34
   55    33    >   QM_ASSIGN                                        ~25     <false>
   53    34    >   ASSIGN                                                   !1, ~25
   57    35        BOOL_NOT                                         ~27     !1
         36      > JMPZ                                                     ~27, ->38
   58    37    > > RETURN                                                   <false>
   61    38    > > RETURN                                                   !1
   62    39*     > RETURN                                                   null

End of function getproviderreferencecode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
191.6 ms | 1411 KiB | 25 Q