3v4l.org

run code in 500+ PHP versions simultaneously
<?php class BookXML extends \DOMDocument { public function filterByYear(int $year) { $books = []; $document = $this; $xpath = new DOMXPath($document); $booksObjs = $document->documentElement; $query = 'string(year)'; foreach ($booksObjs->childNodes as $booksObj) { $yearxml = $xpath->evaluate($query, $booksObj); if ($yearxml == $year) { $books[] = $booksObj; } } return $books; } } $content = ' <xml> <row> <year>2015</year> <month>september</month> </row> </xml> '; $xml = new BookXML(); $xml->loadXML($content); $filteredXML = $xml->filterByYear(2015); print_r($filteredXML);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OA4j1
function name:  (null)
number of ops:  15
compiled vars:  !0 = $content, !1 = $xml, !2 = $filteredXML
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                       !0, '%0A%3Cxml%3E%0A++++%3Crow%3E%0A++++++++%3Cyear%3E2015%3C%2Fyear%3E%0A++++++++%3Cmonth%3Eseptember%3C%2Fmonth%3E%0A++++%3C%2Frow%3E%0A%3C%2Fxml%3E%0A'
   33     1        NEW                                                  $4      'BookXML'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $4
   34     4        INIT_METHOD_CALL                                             !1, 'loadXML'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
   35     7        INIT_METHOD_CALL                                             !1, 'filterByYear'
          8        SEND_VAL_EX                                                  2015
          9        DO_FCALL                                          0  $8      
         10        ASSIGN                                                       !2, $8
   36    11        INIT_FCALL                                                   'print_r'
         12        SEND_VAR                                                     !2
         13        DO_ICALL                                                     
         14      > RETURN                                                       1

Class BookXML:
Function filterbyyear:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/OA4j1
function name:  filterByYear
number of ops:  27
compiled vars:  !0 = $year, !1 = $books, !2 = $document, !3 = $xpath, !4 = $booksObjs, !5 = $query, !6 = $booksObj, !7 = $yearxml
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    9     1        ASSIGN                                                       !1, <array>
   10     2        FETCH_THIS                                           ~9      
          3        ASSIGN                                                       !2, ~9
   11     4        NEW                                                  $11     'DOMXPath'
          5        SEND_VAR_EX                                                  !2
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !3, $11
   12     8        FETCH_OBJ_R                                          ~14     !2, 'documentElement'
          9        ASSIGN                                                       !4, ~14
   13    10        ASSIGN                                                       !5, 'string%28year%29'
   15    11        FETCH_OBJ_R                                          ~17     !4, 'childNodes'
         12      > FE_RESET_R                                           $18     ~17, ->24
         13    > > FE_FETCH_R                                                   $18, !6, ->24
   16    14    >   INIT_METHOD_CALL                                             !3, 'evaluate'
         15        SEND_VAR_EX                                                  !5
         16        SEND_VAR_EX                                                  !6
         17        DO_FCALL                                          0  $19     
         18        ASSIGN                                                       !7, $19
   18    19        IS_EQUAL                                                     !7, !0
         20      > JMPZ                                                         ~21, ->23
   19    21    >   ASSIGN_DIM                                                   !1
         22        OP_DATA                                                      !6
   15    23    > > JMP                                                          ->13
         24    >   FE_FREE                                                      $18
   22    25      > RETURN                                                       !1
   23    26*     > RETURN                                                       null

End of function filterbyyear

End of class BookXML.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.93 ms | 2357 KiB | 14 Q