3v4l.org

run code in 500+ PHP versions simultaneously
<?php class LogParser { public static function getIdsByMessage($xml, $message) { $matches = array(); $xml_parsed = simplexml_load_string($xml); foreach($xml_parsed as $item) { if($item->message == $message) { $attributes = $item->attributes(); $matches[] = (string) $attributes['id']; } } return $matches; } } $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <log> <entry id="1"> <message>Application started</message> </entry> <entry id="2"> <message>Application ended</message> </entry> </log> XML; print_r(LogParser::getIdsByMessage($xml, 'Application ended'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/odFgK
function name:  (null)
number of ops:  9
compiled vars:  !0 = $xml
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                       !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3Clog%3E%0A++++%3Centry+id%3D%221%22%3E%0A++++++++%3Cmessage%3EApplication+started%3C%2Fmessage%3E%0A++++%3C%2Fentry%3E%0A++++%3Centry+id%3D%222%22%3E%0A++++++++%3Cmessage%3EApplication+ended%3C%2Fmessage%3E%0A++++%3C%2Fentry%3E%0A%3C%2Flog%3E'
   29     1        INIT_FCALL                                                   'print_r'
          2        INIT_STATIC_METHOD_CALL                                      'LogParser', 'getIdsByMessage'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     'Application+ended'
          5        DO_FCALL                                          0  $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Class LogParser:
Function getidsbymessage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/odFgK
function name:  getIdsByMessage
number of ops:  23
compiled vars:  !0 = $xml, !1 = $message, !2 = $matches, !3 = $xml_parsed, !4 = $item, !5 = $attributes
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    6     2        ASSIGN                                                       !2, <array>
    7     3        INIT_FCALL                                                   'simplexml_load_string'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $7      
          6        ASSIGN                                                       !3, $7
    8     7      > FE_RESET_R                                           $9      !3, ->20
          8    > > FE_FETCH_R                                                   $9, !4, ->20
    9     9    >   FETCH_OBJ_R                                          ~10     !4, 'message'
         10        IS_EQUAL                                                     !1, ~10
         11      > JMPZ                                                         ~11, ->19
   10    12    >   INIT_METHOD_CALL                                             !4, 'attributes'
         13        DO_FCALL                                          0  $12     
         14        ASSIGN                                                       !5, $12
   11    15        FETCH_DIM_R                                          ~15     !5, 'id'
         16        CAST                                              6  ~16     ~15
         17        ASSIGN_DIM                                                   !2
         18        OP_DATA                                                      ~16
    8    19    > > JMP                                                          ->8
         20    >   FE_FREE                                                      $9
   14    21      > RETURN                                                       !2
   15    22*     > RETURN                                                       null

End of function getidsbymessage

End of class LogParser.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.22 ms | 3339 KiB | 15 Q