3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = "<?xml version='1.0' encoding='ISO-8859-1'?> <delta> <history> <detail> <id>one</id> <degree> <dname>alpha</dname> <dates> <StartDate> <Year>1998</Year> </StartDate> <EndDate> <Year>2002</Year> </EndDate> </dates> </degree> </detail> <detail> <id>two</id> <degree> <dname>beta</dname> <dates> <StartDate> <Year>2006</Year> </StartDate> <EndDate> <Year>2008</Year> </EndDate> </dates> </degree> </detail> </history> </delta>"; $doc = new DOMDocument; $doc->preserveWhiteSpace = false; $doc->loadXML($xml); $xpath = new DOMXPath($doc); $items = $doc->getElementsByTagName("detail"); $subitemarray = array(); $icounter = 0; foreach ($items as $item) { $query = "//*[contains(local-name(), 'Date')] "; $entries = $xpath->query($query, $item); $dates["startdate"] = $entries[0]->nodeValue; $dates["enddate"] = $entries[1]->nodeValue; $subitemarray[$icounter++] = $dates; } var_dump($subitemarray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 39
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 39
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/Aie3G
function name:  (null)
number of ops:  44
compiled vars:  !0 = $xml, !1 = $doc, !2 = $xpath, !3 = $items, !4 = $subitemarray, !5 = $icounter, !6 = $item, !7 = $query, !8 = $entries, !9 = $dates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%271.0%27+encoding%3D%27ISO-8859-1%27%3F%3E%0A%3Cdelta%3E%0A++++%3Chistory%3E%0A++++++++%3Cdetail%3E%0A++++++++++++%3Cid%3Eone%3C%2Fid%3E%0A++++++++++++%3Cdegree%3E%0A++++++++++++++++%3Cdname%3Ealpha%3C%2Fdname%3E%0A++++++++++++++++%3Cdates%3E%0A++++++++++++++++++++%3CStartDate%3E%0A++++++++++++++++++++++++%3CYear%3E1998%3C%2FYear%3E%0A++++++++++++++++++++%3C%2FStartDate%3E%0A++++++++++++++++++++%3CEndDate%3E%0A++++++++++++++++++++++++%3CYear%3E2002%3C%2FYear%3E%0A++++++++++++++++++++%3C%2FEndDate%3E%0A++++++++++++++++%3C%2Fdates%3E%0A++++++++++++%3C%2Fdegree%3E%0A++++++++%3C%2Fdetail%3E%0A++++++++%3Cdetail%3E%0A++++++++++++%3Cid%3Etwo%3C%2Fid%3E%0A++++++++++++%3Cdegree%3E%0A++++++++++++++++%3Cdname%3Ebeta%3C%2Fdname%3E%0A++++++++++++++++%3Cdates%3E%0A++++++++++++++++++++%3CStartDate%3E%0A++++++++++++++++++++++++%3CYear%3E2006%3C%2FYear%3E%0A++++++++++++++++++++%3C%2FStartDate%3E%0A++++++++++++++++++++%3CEndDate%3E%0A++++++++++++++++++++++++%3CYear%3E2008%3C%2FYear%3E%0A++++++++++++++++++++%3C%2FEndDate%3E%0A++++++++++++++++%3C%2Fdates%3E%0A++++++++++++%3C%2Fdegree%3E%0A++++++++%3C%2Fdetail%3E%0A++++%3C%2Fhistory%3E%0A%3C%2Fdelta%3E'
   36     1        NEW                                              $11     'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $11
   37     4        ASSIGN_OBJ                                               !1, 'preserveWhiteSpace'
          5        OP_DATA                                                  <false>
   38     6        INIT_METHOD_CALL                                         !1, 'loadXML'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   39     9        NEW                                              $16     'DOMXPath'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $16
   40    13        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         14        SEND_VAL_EX                                              'detail'
         15        DO_FCALL                                      0  $19     
         16        ASSIGN                                                   !3, $19
   41    17        ASSIGN                                                   !4, <array>
   42    18        ASSIGN                                                   !5, 0
   43    19      > FE_RESET_R                                       $23     !3, ->39
         20    > > FE_FETCH_R                                               $23, !6, ->39
   44    21    >   ASSIGN                                                   !7, '%2F%2F%2A%5Bcontains%28local-name%28%29%2C+%27Date%27%29%5D%0A'
   46    22        INIT_METHOD_CALL                                         !2, 'query'
         23        SEND_VAR_EX                                              !7
         24        SEND_VAR_EX                                              !6
         25        DO_FCALL                                      0  $25     
         26        ASSIGN                                                   !8, $25
   47    27        FETCH_DIM_R                                      ~28     !8, 0
         28        FETCH_OBJ_R                                      ~29     ~28, 'nodeValue'
         29        ASSIGN_DIM                                               !9, 'startdate'
         30        OP_DATA                                                  ~29
   48    31        FETCH_DIM_R                                      ~31     !8, 1
         32        FETCH_OBJ_R                                      ~32     ~31, 'nodeValue'
         33        ASSIGN_DIM                                               !9, 'enddate'
         34        OP_DATA                                                  ~32
   49    35        POST_INC                                         ~33     !5
         36        ASSIGN_DIM                                               !4, ~33
         37        OP_DATA                                                  !9
   43    38      > JMP                                                      ->20
         39    >   FE_FREE                                                  $23
   51    40        INIT_FCALL                                               'var_dump'
         41        SEND_VAR                                                 !4
         42        DO_ICALL                                                 
         43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.71 ms | 1015 KiB | 14 Q