3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$xml = simplexml_load_file('data.xml'); $xml = simplexml_load_string('<items> <item> <images> <image>A</image> <image>B</image> <image>C</image> </images> </item> </items>'); var_dump($xml); // Loop over items in original xml for($i = 0; $i < count($xml->item); $i++) { //$images; if( (count($xml->item[$i]->images->image)) > 1) { $images = $xml->item[$i]->images; // Remove entry unset($xml->item[$i]->images); $xml->item[$i]->addChild('images'); for($y = 0; $y < count($images->image); $y++) { if($y == 0) { $xx = $xml->item[$i]->images->addChild('image', $images->image[$y]); }else { $xml->item[$i]->images->addChild('image' . $y, $images->image[$y]); } } var_dump($images); } } //$xml->asXML('POTO.xml'); echo $xml->asXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 9
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 63
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 30
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 9
Branch analysis from position: 68
Branch analysis from position: 9
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 44
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 30
Branch analysis from position: 60
Branch analysis from position: 30
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 30
Branch analysis from position: 60
Branch analysis from position: 30
Branch analysis from position: 63
filename:       /in/Wg27h
function name:  (null)
number of ops:  72
compiled vars:  !0 = $xml, !1 = $i, !2 = $images, !3 = $y, !4 = $xx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'simplexml_load_string'
          1        SEND_VAL                                                 '%3Citems%3E%0A++%3Citem%3E%0A++++%3Cimages%3E%0A++++++%3Cimage%3EA%3C%2Fimage%3E%0A++++++%3Cimage%3EB%3C%2Fimage%3E%0A++++++%3Cimage%3EC%3C%2Fimage%3E%0A++++%3C%2Fimages%3E%0A++%3C%2Fitem%3E%0A%3C%2Fitems%3E'
          2        DO_ICALL                                         $5      
          3        ASSIGN                                                   !0, $5
   12     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
   16     7        ASSIGN                                                   !1, 0
          8      > JMP                                                      ->64
   19     9    >   FETCH_OBJ_R                                      ~9      !0, 'item'
         10        FETCH_DIM_R                                      ~10     ~9, !1
         11        FETCH_OBJ_R                                      ~11     ~10, 'images'
         12        FETCH_OBJ_R                                      ~12     ~11, 'image'
         13        COUNT                                            ~13     ~12
         14        IS_SMALLER                                               1, ~13
         15      > JMPZ                                                     ~14, ->63
   21    16    >   FETCH_OBJ_R                                      ~15     !0, 'item'
         17        FETCH_DIM_R                                      ~16     ~15, !1
         18        FETCH_OBJ_R                                      ~17     ~16, 'images'
         19        ASSIGN                                                   !2, ~17
   24    20        FETCH_OBJ_UNSET                                  $19     !0, 'item'
         21        FETCH_DIM_UNSET                                  $20     $19, !1
         22        UNSET_OBJ                                                $20, 'images'
   26    23        FETCH_OBJ_R                                      ~21     !0, 'item'
         24        FETCH_DIM_R                                      ~22     ~21, !1
         25        INIT_METHOD_CALL                                         ~22, 'addChild'
         26        SEND_VAL_EX                                              'images'
         27        DO_FCALL                                      0          
   28    28        ASSIGN                                                   !3, 0
         29      > JMP                                                      ->56
   30    30    >   IS_EQUAL                                                 !3, 0
         31      > JMPZ                                                     ~25, ->44
   32    32    >   FETCH_OBJ_R                                      ~26     !0, 'item'
         33        FETCH_DIM_R                                      ~27     ~26, !1
         34        FETCH_OBJ_R                                      ~28     ~27, 'images'
         35        INIT_METHOD_CALL                                         ~28, 'addChild'
         36        SEND_VAL_EX                                              'image'
         37        CHECK_FUNC_ARG                                           
         38        FETCH_OBJ_FUNC_ARG                               $29     !2, 'image'
         39        FETCH_DIM_FUNC_ARG                               $30     $29, !3
         40        SEND_FUNC_ARG                                            $30
         41        DO_FCALL                                      0  $31     
         42        ASSIGN                                                   !4, $31
         43      > JMP                                                      ->55
   35    44    >   FETCH_OBJ_R                                      ~33     !0, 'item'
         45        FETCH_DIM_R                                      ~34     ~33, !1
         46        FETCH_OBJ_R                                      ~35     ~34, 'images'
         47        INIT_METHOD_CALL                                         ~35, 'addChild'
         48        CONCAT                                           ~36     'image', !3
         49        SEND_VAL_EX                                              ~36
         50        CHECK_FUNC_ARG                                           
         51        FETCH_OBJ_FUNC_ARG                               $37     !2, 'image'
         52        FETCH_DIM_FUNC_ARG                               $38     $37, !3
         53        SEND_FUNC_ARG                                            $38
         54        DO_FCALL                                      0          
   28    55    >   PRE_INC                                                  !3
         56    >   FETCH_OBJ_R                                      ~41     !2, 'image'
         57        COUNT                                            ~42     ~41
         58        IS_SMALLER                                               !3, ~42
         59      > JMPNZ                                                    ~43, ->30
   39    60    >   INIT_FCALL                                               'var_dump'
         61        SEND_VAR                                                 !2
         62        DO_ICALL                                                 
   16    63    >   PRE_INC                                                  !1
         64    >   FETCH_OBJ_R                                      ~46     !0, 'item'
         65        COUNT                                            ~47     ~46
         66        IS_SMALLER                                               !1, ~47
         67      > JMPNZ                                                    ~48, ->9
   44    68    >   INIT_METHOD_CALL                                         !0, 'asXML'
         69        DO_FCALL                                      0  $49     
         70        ECHO                                                     $49
         71      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.89 ms | 1400 KiB | 17 Q