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>'); // Loop over items in original xml for($i = 0; $i < count($xml->item); $i++) { $images; if( ($c = 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 = 62
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 6
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 61
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 28
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 6
Branch analysis from position: 66
Branch analysis from position: 6
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 42
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 28
Branch analysis from position: 58
Branch analysis from position: 28
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 28
Branch analysis from position: 58
Branch analysis from position: 28
Branch analysis from position: 61
filename:       /in/qOu2H
function name:  (null)
number of ops:  70
compiled vars:  !0 = $xml, !1 = $i, !2 = $images, !3 = $c, !4 = $y, !5 = $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                                         $6      
          3        ASSIGN                                                   !0, $6
   15     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->62
   18     6    >   FETCH_OBJ_R                                      ~9      !0, 'item'
          7        FETCH_DIM_R                                      ~10     ~9, !1
          8        FETCH_OBJ_R                                      ~11     ~10, 'images'
          9        FETCH_OBJ_R                                      ~12     ~11, 'image'
         10        COUNT                                            ~13     ~12
         11        ASSIGN                                           ~14     !3, ~13
         12        IS_SMALLER                                               1, ~14
         13      > JMPZ                                                     ~15, ->61
   20    14    >   FETCH_OBJ_R                                      ~16     !0, 'item'
         15        FETCH_DIM_R                                      ~17     ~16, !1
         16        FETCH_OBJ_R                                      ~18     ~17, 'images'
         17        ASSIGN                                                   !2, ~18
   23    18        FETCH_OBJ_UNSET                                  $20     !0, 'item'
         19        FETCH_DIM_UNSET                                  $21     $20, !1
         20        UNSET_OBJ                                                $21, 'images'
   25    21        FETCH_OBJ_R                                      ~22     !0, 'item'
         22        FETCH_DIM_R                                      ~23     ~22, !1
         23        INIT_METHOD_CALL                                         ~23, 'addChild'
         24        SEND_VAL_EX                                              'images'
         25        DO_FCALL                                      0          
   27    26        ASSIGN                                                   !4, 0
         27      > JMP                                                      ->54
   29    28    >   IS_EQUAL                                                 !4, 0
         29      > JMPZ                                                     ~26, ->42
   31    30    >   FETCH_OBJ_R                                      ~27     !0, 'item'
         31        FETCH_DIM_R                                      ~28     ~27, !1
         32        FETCH_OBJ_R                                      ~29     ~28, 'images'
         33        INIT_METHOD_CALL                                         ~29, 'addChild'
         34        SEND_VAL_EX                                              'image'
         35        CHECK_FUNC_ARG                                           
         36        FETCH_OBJ_FUNC_ARG                               $30     !2, 'image'
         37        FETCH_DIM_FUNC_ARG                               $31     $30, !4
         38        SEND_FUNC_ARG                                            $31
         39        DO_FCALL                                      0  $32     
         40        ASSIGN                                                   !5, $32
         41      > JMP                                                      ->53
   34    42    >   FETCH_OBJ_R                                      ~34     !0, 'item'
         43        FETCH_DIM_R                                      ~35     ~34, !1
         44        FETCH_OBJ_R                                      ~36     ~35, 'images'
         45        INIT_METHOD_CALL                                         ~36, 'addChild'
         46        CONCAT                                           ~37     'image', !4
         47        SEND_VAL_EX                                              ~37
         48        CHECK_FUNC_ARG                                           
         49        FETCH_OBJ_FUNC_ARG                               $38     !2, 'image'
         50        FETCH_DIM_FUNC_ARG                               $39     $38, !4
         51        SEND_FUNC_ARG                                            $39
         52        DO_FCALL                                      0          
   27    53    >   PRE_INC                                                  !4
         54    >   FETCH_OBJ_R                                      ~42     !2, 'image'
         55        COUNT                                            ~43     ~42
         56        IS_SMALLER                                               !4, ~43
         57      > JMPNZ                                                    ~44, ->28
   38    58    >   INIT_FCALL                                               'var_dump'
         59        SEND_VAR                                                 !2
         60        DO_ICALL                                                 
   15    61    >   PRE_INC                                                  !1
         62    >   FETCH_OBJ_R                                      ~47     !0, 'item'
         63        COUNT                                            ~48     ~47
         64        IS_SMALLER                                               !1, ~48
         65      > JMPNZ                                                    ~49, ->6
   43    66    >   INIT_METHOD_CALL                                         !0, 'asXML'
         67        DO_FCALL                                      0  $50     
         68        ECHO                                                     $50
         69      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.52 ms | 1392 KiB | 17 Q