3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <translations> <translation id="title"> <english name="name1" ad="ad1">Hello there, how are you?</english> <italian name="name2" ad="ad2">Ciao, come stai?</italian> </translation> <translation id="text2"> <english name="name3" ad="ad4">222Hello there, how are you?</english> <italian name="name3" ad="ad4">222Ciao, come stai?</italian> </translation> <translation id="text3"> <english name="name5" ad="ad5">333Hello there, how are you?</english> <italian name="name6" ad="ad6">333Ciao, come stai?</italian> </translation> </translations>'; $xml = new SimpleXMLElement($xml); //var_dump($xml->translation); //echo $xml->translations->translation->english['ad']; //echo $xml->translations->translation->italian['name']; foreach ($xml->translation as $element) { foreach($element as $key => $val) { echo $element['id']."{$key}: {$val}".PHP_EOL; } } $xml = simplexml_load_string($xml); $json = json_encode($xml); $array = json_decode($json,TRUE); var_dump($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/deXvE
function name:  (null)
number of ops:  39
compiled vars:  !0 = $xml, !1 = $element, !2 = $val, !3 = $key, !4 = $json, !5 = $array
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%22title%22%3E%0A++++++++%3Cenglish+name%3D%22name1%22+ad%3D%22ad1%22%3EHello+there%2C+how+are+you%3F%3C%2Fenglish%3E%0A++++++++%3Citalian+name%3D%22name2%22+ad%3D%22ad2%22%3ECiao%2C+come+stai%3F%3C%2Fitalian%3E%0A++++%3C%2Ftranslation%3E%0A++++%3Ctranslation+id%3D%22text2%22%3E%0A++++++++%3Cenglish+name%3D%22name3%22+ad%3D%22ad4%22%3E222Hello+there%2C+how+are+you%3F%3C%2Fenglish%3E%0A++++++++%3Citalian+name%3D%22name3%22+ad%3D%22ad4%22%3E222Ciao%2C+come+stai%3F%3C%2Fitalian%3E%0A++++%3C%2Ftranslation%3E%0A++++%3Ctranslation+id%3D%22text3%22%3E%0A++++++++%3Cenglish+name%3D%22name5%22+ad%3D%22ad5%22%3E333Hello+there%2C+how+are+you%3F%3C%2Fenglish%3E%0A++++++++%3Citalian+name%3D%22name6%22+ad%3D%22ad6%22%3E333Ciao%2C+come+stai%3F%3C%2Fitalian%3E%0A++++%3C%2Ftranslation%3E%0A%3C%2Ftranslations%3E'
   20     1        NEW                                              $7      'SimpleXMLElement'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $7
   27     5        FETCH_OBJ_R                                      ~10     !0, 'translation'
          6      > FE_RESET_R                                       $11     ~10, ->21
          7    > > FE_FETCH_R                                               $11, !1, ->21
   28     8    > > FE_RESET_R                                       $12     !1, ->19
          9    > > FE_FETCH_R                                       ~13     $12, !2, ->19
         10    >   ASSIGN                                                   !3, ~13
   29    11        FETCH_DIM_R                                      ~15     !1, 'id'
         12        ROPE_INIT                                     3  ~17     !3
         13        ROPE_ADD                                      1  ~17     ~17, '%3A+'
         14        ROPE_END                                      2  ~16     ~17, !2
         15        CONCAT                                           ~19     ~15, ~16
         16        CONCAT                                           ~20     ~19, '%0A'
         17        ECHO                                                     ~20
   28    18      > JMP                                                      ->9
         19    >   FE_FREE                                                  $12
   27    20      > JMP                                                      ->7
         21    >   FE_FREE                                                  $11
   33    22        INIT_FCALL                                               'simplexml_load_string'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $21     
         25        ASSIGN                                                   !0, $21
   34    26        INIT_FCALL                                               'json_encode'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $23     
         29        ASSIGN                                                   !4, $23
   35    30        INIT_FCALL                                               'json_decode'
         31        SEND_VAR                                                 !4
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $25     
         34        ASSIGN                                                   !5, $25
   37    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !5
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.8 ms | 1400 KiB | 21 Q