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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.31 ms | 1400 KiB | 15 Q