3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = "<root> <parent> <child name='Child1' /> <child name='Child2' /> <subparent name='subchild'> naiya </subparent> </parent> <child name='Child4' /> </root>"; $xml = simplexml_load_string( $xml); foreach( $xml->xpath->query( '//child[@name="Child2"]')-> children as $child) { $attributes = $child->attributes(); echo $attributes['name'] . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/sCgYn
function name:  (null)
number of ops:  21
compiled vars:  !0 = $xml, !1 = $child, !2 = $attributes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Croot%3E%0A++++%3Cparent%3E%0A++++++++%3Cchild+name%3D%27Child1%27+%2F%3E%0A++++++++%3Cchild+name%3D%27Child2%27+%2F%3E%0A++++++++%3Csubparent+name%3D%27subchild%27%3E%0A++++++++++++naiya%0A++++++++%3C%2Fsubparent%3E%0A++++%3C%2Fparent%3E%0A++++%3Cchild+name%3D%27Child4%27+%2F%3E%0A%3C%2Froot%3E'
   13     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !0, $4
   16     5        FETCH_OBJ_R                                      ~6      !0, 'xpath'
          6        INIT_METHOD_CALL                                         ~6, 'query'
          7        SEND_VAL_EX                                              '%2F%2Fchild%5B%40name%3D%22Child2%22%5D'
          8        DO_FCALL                                      0  $7      
          9        FETCH_OBJ_R                                      ~8      $7, 'children'
         10      > FE_RESET_R                                       $9      ~8, ->19
         11    > > FE_FETCH_R                                               $9, !1, ->19
   17    12    >   INIT_METHOD_CALL                                         !1, 'attributes'
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !2, $10
   18    15        FETCH_DIM_R                                      ~12     !2, 'name'
         16        CONCAT                                           ~13     ~12, '%0A'
         17        ECHO                                                     ~13
   16    18      > JMP                                                      ->11
         19    >   FE_FREE                                                  $9
   19    20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.56 ms | 1400 KiB | 15 Q