3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dom=new DOMDocument(); $dom->loadXML(<<<XML <?xml version="1.0"?> <alerts> <alert> <id>3</id> <msg_type>1</msg_type> <msg>Some Message</msg> <url>Some Link</url> <status>0</status> <create_date>1388049941</create_date> <update_date>1388052529</update_date> </alert> <alert> <id>6</id> <msg_type>1</msg_type> <msg>Some Message</msg> <url>Some Link</url> <status>0</status> <create_date>1388049941</create_date> <update_date>1388052529</update_date> </alert> <alert> <id>14</id> <msg_type>1</msg_type> <msg>Some Message</msg> <url>Some Link</url> <status>0</status> <create_date>1388049941</create_date> <update_date>1388052529</update_date> </alert> <alert> <id>24</id> <msg_type>1</msg_type> <msg>Some Message</msg> <url>Some Link</url> <status>0</status> <create_date>1388049941</create_date> <update_date>1388052529</update_date> </alert> </alerts> XML ); $target=new DOMDocument(); $target->loadXML(<<<XML <?xml version="1.0"?> <alerts> </alerts> XML ); $xpath=new DOMXPath($dom); $nodeList=$xpath->query('alert[msg_type=1]'); $myID=14; foreach($nodeList as $node) { foreach($node->childNodes as $child) { if($child->nodeName=="id") { if($child->textContent==$myID) { $target->documentElement->appendChild($target->importNode($node,true)); $node->parentNode->removeChild($node); } break; } } } echo $dom->saveXML(); echo "\n"; echo $target->saveXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 48
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 48
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 46
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 46
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 45
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 44
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 44
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 46
Branch analysis from position: 46
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/avFJI
function name:  (null)
number of ops:  57
compiled vars:  !0 = $dom, !1 = $target, !2 = $xpath, !3 = $nodeList, !4 = $myID, !5 = $node, !6 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $7      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $7
    3     3        INIT_METHOD_CALL                                         !0, 'loadXML'
    4     4        SEND_VAL_EX                                              '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Calerts%3E%0A++%3Calert%3E%0A++++%3Cid%3E3%3C%2Fid%3E%0A++++%3Cmsg_type%3E1%3C%2Fmsg_type%3E%0A++++%3Cmsg%3ESome+Message%3C%2Fmsg%3E%0A++++%3Curl%3ESome+Link%3C%2Furl%3E%0A++++%3Cstatus%3E0%3C%2Fstatus%3E%0A++++%3Ccreate_date%3E1388049941%3C%2Fcreate_date%3E%0A++++%3Cupdate_date%3E1388052529%3C%2Fupdate_date%3E%0A++%3C%2Falert%3E%0A++%3Calert%3E%0A++++%3Cid%3E6%3C%2Fid%3E%0A++++%3Cmsg_type%3E1%3C%2Fmsg_type%3E%0A++++%3Cmsg%3ESome+Message%3C%2Fmsg%3E%0A++++%3Curl%3ESome+Link%3C%2Furl%3E%0A++++%3Cstatus%3E0%3C%2Fstatus%3E%0A++++%3Ccreate_date%3E1388049941%3C%2Fcreate_date%3E%0A++++%3Cupdate_date%3E1388052529%3C%2Fupdate_date%3E%0A++%3C%2Falert%3E%0A++%3Calert%3E%0A++++%3Cid%3E14%3C%2Fid%3E%0A++++%3Cmsg_type%3E1%3C%2Fmsg_type%3E%0A++++%3Cmsg%3ESome+Message%3C%2Fmsg%3E%0A+++%3Curl%3ESome+Link%3C%2Furl%3E%0A++++%3Cstatus%3E0%3C%2Fstatus%3E%0A++++%3Ccreate_date%3E1388049941%3C%2Fcreate_date%3E%0A++++%3Cupdate_date%3E1388052529%3C%2Fupdate_date%3E%0A++%3C%2Falert%3E%0A++%3Calert%3E%0A++++%3Cid%3E24%3C%2Fid%3E%0A++++%3Cmsg_type%3E1%3C%2Fmsg_type%3E%0A++++%3Cmsg%3ESome+Message%3C%2Fmsg%3E%0A++++%3Curl%3ESome+Link%3C%2Furl%3E%0A++++%3Cstatus%3E0%3C%2Fstatus%3E%0A++++%3Ccreate_date%3E1388049941%3C%2Fcreate_date%3E%0A++++%3Cupdate_date%3E1388052529%3C%2Fupdate_date%3E%0A++%3C%2Falert%3E%0A%3C%2Falerts%3E'
          5        DO_FCALL                                      0          
   45     6        NEW                                              $11     'DOMDocument'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $11
   46     9        INIT_METHOD_CALL                                         !1, 'loadXML'
   47    10        SEND_VAL_EX                                              '%3C%3Fxml+version%3D%221.0%22%3F%3E%0A%3Calerts%3E%0A%3C%2Falerts%3E'
         11        DO_FCALL                                      0          
   52    12        NEW                                              $15     'DOMXPath'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !2, $15
   53    16        INIT_METHOD_CALL                                         !2, 'query'
         17        SEND_VAL_EX                                              'alert%5Bmsg_type%3D1%5D'
         18        DO_FCALL                                      0  $18     
         19        ASSIGN                                                   !3, $18
   54    20        ASSIGN                                                   !4, 14
   55    21      > FE_RESET_R                                       $21     !3, ->48
         22    > > FE_FETCH_R                                               $21, !5, ->48
   57    23    >   FETCH_OBJ_R                                      ~22     !5, 'childNodes'
         24      > FE_RESET_R                                       $23     ~22, ->46
         25    > > FE_FETCH_R                                               $23, !6, ->46
   59    26    >   FETCH_OBJ_R                                      ~24     !6, 'nodeName'
         27        IS_EQUAL                                                 ~24, 'id'
         28      > JMPZ                                                     ~25, ->45
   61    29    >   FETCH_OBJ_R                                      ~26     !6, 'textContent'
         30        IS_EQUAL                                                 !4, ~26
         31      > JMPZ                                                     ~27, ->44
   63    32    >   FETCH_OBJ_R                                      ~28     !1, 'documentElement'
         33        INIT_METHOD_CALL                                         ~28, 'appendChild'
         34        INIT_METHOD_CALL                                         !1, 'importNode'
         35        SEND_VAR_EX                                              !5
         36        SEND_VAL_EX                                              <true>
         37        DO_FCALL                                      0  $29     
         38        SEND_VAR_NO_REF_EX                                       $29
         39        DO_FCALL                                      0          
   64    40        FETCH_OBJ_R                                      ~31     !5, 'parentNode'
         41        INIT_METHOD_CALL                                         ~31, 'removeChild'
         42        SEND_VAR_EX                                              !5
         43        DO_FCALL                                      0          
   66    44    > > JMP                                                      ->46
   57    45    > > JMP                                                      ->25
         46    >   FE_FREE                                                  $23
   55    47      > JMP                                                      ->22
         48    >   FE_FREE                                                  $21
   70    49        INIT_METHOD_CALL                                         !0, 'saveXML'
         50        DO_FCALL                                      0  $33     
         51        ECHO                                                     $33
   71    52        ECHO                                                     '%0A'
   72    53        INIT_METHOD_CALL                                         !1, 'saveXML'
         54        DO_FCALL                                      0  $34     
         55        ECHO                                                     $34
         56      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.56 ms | 1403 KiB | 13 Q