3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = <<<XML <?xml version="1.0" encoding="ISO-8859-1"?> <PersonList> <Person> <Name>Sonu Kapoor</Name> <Age>24</Age> <Gender>M</Gender> <PostalCode>54879</PostalCode> </Person> <Person> <Name>Jasmin</Name> <Age>28</Age> <Gender>M</Gender> <PostalCode>78745</PostalCode> </Person> <Person> <Name>Josef</Name> <Age>232</Age> <Gender>F</Gender> <PostalCode>53454</PostalCode> </Person> </PersonList> XML; $doc = new DOMDocument(); $doc->loadXML($content); $xp = new DOMXPath($doc); $nodeList = $xp->query('/PersonList/Person[./Name="Jasmin"]/*'); for($i = 0; $i < $nodeList->length; $i++) { switch ($nodeList->item($i)->nodeName) { case 'Age': $nodeList->item($i)->nodeValue = 33; break; case 'Gender': $nodeList->item($i)->nodeValue = 'F'; break; } } $doc->formatOutput = true; echo $doc->saveXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 17
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
4 jumps found. (Code = 188) Position 1 = 27, Position 2 = 34, Position 3 = 41, Position 4 = 22
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 17
Branch analysis from position: 46
Branch analysis from position: 17
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 41
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 34
Branch analysis from position: 27
filename:       /in/Cqq4D
function name:  (null)
number of ops:  52
compiled vars:  !0 = $content, !1 = $doc, !2 = $xp, !3 = $nodeList, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22ISO-8859-1%22%3F%3E%0A%3CPersonList%3E%0A++%3CPerson%3E%0A++++%3CName%3ESonu+Kapoor%3C%2FName%3E%0A++++%3CAge%3E24%3C%2FAge%3E%0A++++%3CGender%3EM%3C%2FGender%3E%0A++++%3CPostalCode%3E54879%3C%2FPostalCode%3E%0A++%3C%2FPerson%3E%0A++%3CPerson%3E%0A++++%3CName%3EJasmin%3C%2FName%3E%0A++++%3CAge%3E28%3C%2FAge%3E%0A++++%3CGender%3EM%3C%2FGender%3E%0A++++%3CPostalCode%3E78745%3C%2FPostalCode%3E%0A++%3C%2FPerson%3E%0A+++%3CPerson%3E%0A++++%3CName%3EJosef%3C%2FName%3E%0A++++%3CAge%3E232%3C%2FAge%3E%0A++++%3CGender%3EF%3C%2FGender%3E%0A++++%3CPostalCode%3E53454%3C%2FPostalCode%3E%0A++%3C%2FPerson%3E%0A%3C%2FPersonList%3E'
   26     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   27     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   28     7        NEW                                              $10     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   29    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2FPersonList%2FPerson%5B.%2FName%3D%22Jasmin%22%5D%2F%2A'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !3, $13
   30    15        ASSIGN                                                   !4, 0
         16      > JMP                                                      ->43
   31    17    >   INIT_METHOD_CALL                                         !3, 'item'
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0  $16     
         20        FETCH_OBJ_R                                      ~17     $16, 'nodeName'
         21      > SWITCH_STRING                                            ~17, [ 'Age':->27, 'Gender':->34, ], ->41
   32    22    >   CASE                                                     ~17, 'Age'
         23      > JMPNZ                                                    ~18, ->27
   35    24    >   CASE                                                     ~17, 'Gender'
         25      > JMPNZ                                                    ~18, ->34
         26    > > JMP                                                      ->41
   33    27    >   INIT_METHOD_CALL                                         !3, 'item'
         28        SEND_VAR_EX                                              !4
         29        DO_FCALL                                      0  $19     
         30        SEPARATE                                         $19     $19
         31        ASSIGN_OBJ                                               $19, 'nodeValue'
         32        OP_DATA                                                  33
   34    33      > JMP                                                      ->41
   36    34    >   INIT_METHOD_CALL                                         !3, 'item'
         35        SEND_VAR_EX                                              !4
         36        DO_FCALL                                      0  $21     
         37        SEPARATE                                         $21     $21
         38        ASSIGN_OBJ                                               $21, 'nodeValue'
         39        OP_DATA                                                  'F'
   37    40      > JMP                                                      ->41
         41    >   FREE                                                     ~17
   30    42        PRE_INC                                                  !4
         43    >   FETCH_OBJ_R                                      ~24     !3, 'length'
         44        IS_SMALLER                                               !4, ~24
         45      > JMPNZ                                                    ~25, ->17
   40    46    >   ASSIGN_OBJ                                               !1, 'formatOutput'
         47        OP_DATA                                                  <true>
   41    48        INIT_METHOD_CALL                                         !1, 'saveXML'
         49        DO_FCALL                                      0  $27     
         50        ECHO                                                     $27
         51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.4 ms | 1399 KiB | 13 Q