3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <translations> <translation id="id1"> <es>Español1</es> <en>English1</en> </translation> <translation id="id2"> <es>Español2</es> <en>English2</en> </translation> <translation id="id3"> <es>Español3</es> <en>English13</en> </translation> </translations>'; $xml = new SimpleXMLElement($xml); $xml = $xml->translation; function translate($xml, $id, $lang) { foreach ($xml as $element) { if($element['id'] == $id) { return $element->{$lang}; } } } echo translate($xml, 'id1', 'es'); echo translate($xml, 'id1', 'en'); echo translate($xml, 'id2', 'es'); echo translate($xml, 'id2', 'en'); echo translate($xml, 'id3', 'es'); echo translate($xml, 'id3', 'en');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ccta
function name:  (null)
number of ops:  44
compiled vars:  !0 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3Ctranslations%3E%0A++++%3Ctranslation+id%3D%22id1%22%3E%0A++++++++%3Ces%3EEspa%C3%B1ol1%3C%2Fes%3E%0A++++++++%3Cen%3EEnglish1%3C%2Fen%3E%0A++++%3C%2Ftranslation%3E%0A++++%3Ctranslation+id%3D%22id2%22%3E%0A++++++++%3Ces%3EEspa%C3%B1ol2%3C%2Fes%3E%0A++++++++%3Cen%3EEnglish2%3C%2Fen%3E%0A++++%3C%2Ftranslation%3E%0A++++%3Ctranslation+id%3D%22id3%22%3E%0A++++++++%3Ces%3EEspa%C3%B1ol3%3C%2Fes%3E%0A++++++++%3Cen%3EEnglish13%3C%2Fen%3E%0A++++%3C%2Ftranslation%3E%0A%3C%2Ftranslations%3E'
   18     1        NEW                                              $2      'SimpleXMLElement'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   19     5        FETCH_OBJ_R                                      ~5      !0, 'translation'
          6        ASSIGN                                                   !0, ~5
   31     7        INIT_FCALL                                               'translate'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 'id1'
         10        SEND_VAL                                                 'es'
         11        DO_FCALL                                      0  $7      
         12        ECHO                                                     $7
   32    13        INIT_FCALL                                               'translate'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 'id1'
         16        SEND_VAL                                                 'en'
         17        DO_FCALL                                      0  $8      
         18        ECHO                                                     $8
   33    19        INIT_FCALL                                               'translate'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 'id2'
         22        SEND_VAL                                                 'es'
         23        DO_FCALL                                      0  $9      
         24        ECHO                                                     $9
   34    25        INIT_FCALL                                               'translate'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 'id2'
         28        SEND_VAL                                                 'en'
         29        DO_FCALL                                      0  $10     
         30        ECHO                                                     $10
   35    31        INIT_FCALL                                               'translate'
         32        SEND_VAR                                                 !0
         33        SEND_VAL                                                 'id3'
         34        SEND_VAL                                                 'es'
         35        DO_FCALL                                      0  $11     
         36        ECHO                                                     $11
   36    37        INIT_FCALL                                               'translate'
         38        SEND_VAR                                                 !0
         39        SEND_VAL                                                 'id3'
         40        SEND_VAL                                                 'en'
         41        DO_FCALL                                      0  $12     
         42        ECHO                                                     $12
         43      > RETURN                                                   1

Function translate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/3ccta
function name:  translate
number of ops:  14
compiled vars:  !0 = $xml, !1 = $id, !2 = $lang, !3 = $element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   23     3      > FE_RESET_R                                       $4      !0, ->12
          4    > > FE_FETCH_R                                               $4, !3, ->12
   24     5    >   FETCH_DIM_R                                      ~5      !3, 'id'
          6        IS_EQUAL                                                 !1, ~5
          7      > JMPZ                                                     ~6, ->11
   25     8    >   FETCH_OBJ_R                                      ~7      !3, !2
          9        FE_FREE                                                  $4
         10      > RETURN                                                   ~7
   23    11    > > JMP                                                      ->4
         12    >   FE_FREE                                                  $4
   29    13      > RETURN                                                   null

End of function translate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.9 ms | 1407 KiB | 19 Q