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; var_dump($images); // Remove entry unset($xml->item[$i]->images); $xml->item[$i]->addChild('images'); for($y = 0; $y < $images->image->count(); $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 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 9
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 67
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 33
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 9
Branch analysis from position: 72
Branch analysis from position: 9
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 47
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 33
Branch analysis from position: 64
Branch analysis from position: 33
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 64, Position 2 = 33
Branch analysis from position: 64
Branch analysis from position: 33
Branch analysis from position: 67
filename:       /in/0HabJ
function name:  (null)
number of ops:  76
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                                                      ->68
   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, ->67
   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
   22    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                                 
   25    23        FETCH_OBJ_UNSET                                  $20     !0, 'item'
         24        FETCH_DIM_UNSET                                  $21     $20, !1
         25        UNSET_OBJ                                                $21, 'images'
   27    26        FETCH_OBJ_R                                      ~22     !0, 'item'
         27        FETCH_DIM_R                                      ~23     ~22, !1
         28        INIT_METHOD_CALL                                         ~23, 'addChild'
         29        SEND_VAL_EX                                              'images'
         30        DO_FCALL                                      0          
   29    31        ASSIGN                                                   !3, 0
         32      > JMP                                                      ->59
   31    33    >   IS_EQUAL                                                 !3, 0
         34      > JMPZ                                                     ~26, ->47
   33    35    >   FETCH_OBJ_R                                      ~27     !0, 'item'
         36        FETCH_DIM_R                                      ~28     ~27, !1
         37        FETCH_OBJ_R                                      ~29     ~28, 'images'
         38        INIT_METHOD_CALL                                         ~29, 'addChild'
         39        SEND_VAL_EX                                              'image'
         40        CHECK_FUNC_ARG                                           
         41        FETCH_OBJ_FUNC_ARG                               $30     !2, 'image'
         42        FETCH_DIM_FUNC_ARG                               $31     $30, !3
         43        SEND_FUNC_ARG                                            $31
         44        DO_FCALL                                      0  $32     
         45        ASSIGN                                                   !4, $32
         46      > JMP                                                      ->58
   36    47    >   FETCH_OBJ_R                                      ~34     !0, 'item'
         48        FETCH_DIM_R                                      ~35     ~34, !1
         49        FETCH_OBJ_R                                      ~36     ~35, 'images'
         50        INIT_METHOD_CALL                                         ~36, 'addChild'
         51        CONCAT                                           ~37     'image', !3
         52        SEND_VAL_EX                                              ~37
         53        CHECK_FUNC_ARG                                           
         54        FETCH_OBJ_FUNC_ARG                               $38     !2, 'image'
         55        FETCH_DIM_FUNC_ARG                               $39     $38, !3
         56        SEND_FUNC_ARG                                            $39
         57        DO_FCALL                                      0          
   29    58    >   PRE_INC                                                  !3
         59    >   FETCH_OBJ_R                                      ~42     !2, 'image'
         60        INIT_METHOD_CALL                                         ~42, 'count'
         61        DO_FCALL                                      0  $43     
         62        IS_SMALLER                                               !3, $43
         63      > JMPNZ                                                    ~44, ->33
   40    64    >   INIT_FCALL                                               'var_dump'
         65        SEND_VAR                                                 !2
         66        DO_ICALL                                                 
   16    67    >   PRE_INC                                                  !1
         68    >   FETCH_OBJ_R                                      ~47     !0, 'item'
         69        COUNT                                            ~48     ~47
         70        IS_SMALLER                                               !1, ~48
         71      > JMPNZ                                                    ~49, ->9
   45    72    >   INIT_METHOD_CALL                                         !0, 'asXML'
         73        DO_FCALL                                      0  $50     
         74        ECHO                                                     $50
         75      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.37 ms | 1404 KiB | 17 Q