3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array('x' => array('value' => 'test')); $doc = new \SimpleXMLElement('<resource href="/"></resource>'); foreach ($data as $key => $value) { if (is_array($value) || $value instanceof \Traversable) { if (!is_numeric($key)) { if (count($value) > 0 && isset($value[0])) { $this->arrayToXml($value, $element, $key); } else { $subnode = $element->addChild($key); $this->arrayToXml($value, $subnode, $key); } } else { $subnode = $element->addChild($parent); $this->arrayToXml($value, $subnode, $parent); } } else { if (!is_numeric($key)) { if (substr($key, 0, 1) === '@') { $element->addAttribute(substr($key, 1), $value); } elseif ($key === 'value' and count($data) === 1) { $element->{0} = $value; } elseif (is_bool($value)) { $element->addChild($key, intval($value)); } else { $element->addChild($key, htmlspecialchars($value, ENT_QUOTES)); } } else { $element->addChild($parent, htmlspecialchars($value, ENT_QUOTES)); } } } echo $doc->x; //$xml = new \SimpleXMLElement('<resource href="/"><x><0>test</0></x></resource>'); //echo $xml->x;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 109
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 109
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 53
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 42
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 23
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 100
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 74
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
Branch analysis from position: 74
2 jumps found. (Code = 46) Position 1 = 76, Position 2 = 79
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 83
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
Branch analysis from position: 83
2 jumps found. (Code = 43) Position 1 = 85, Position 2 = 91
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
Branch analysis from position: 91
1 jumps found. (Code = 42) Position 1 = 108
Branch analysis from position: 108
Branch analysis from position: 79
Branch analysis from position: 100
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
Branch analysis from position: 109
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 109
filename:       /in/GZnl1
function name:  (null)
number of ops:  113
compiled vars:  !0 = $data, !1 = $doc, !2 = $value, !3 = $key, !4 = $element, !5 = $subnode, !6 = $parent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        NEW                                              $8      'SimpleXMLElement'
          2        SEND_VAL_EX                                              '%3Cresource+href%3D%22%2F%22%3E%3C%2Fresource%3E'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $8
    5     5      > FE_RESET_R                                       $11     !0, ->109
          6    > > FE_FETCH_R                                       ~12     $11, !2, ->109
          7    >   ASSIGN                                                   !3, ~12
    6     8        TYPE_CHECK                                  128  ~14     !2
          9      > JMPNZ_EX                                         ~14     ~14, ->12
         10    >   INSTANCEOF                                       ~15     !2, 'Traversable'
         11        BOOL                                             ~14     ~15
         12    > > JMPZ                                                     ~14, ->53
    7    13    >   INIT_FCALL                                               'is_numeric'
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $16     
         16        BOOL_NOT                                         ~17     $16
         17      > JMPZ                                                     ~17, ->42
    8    18    >   COUNT                                            ~18     !2
         19        IS_SMALLER                                       ~19     0, ~18
         20      > JMPZ_EX                                          ~19     ~19, ->23
         21    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~20     !2, 0
         22        BOOL                                             ~19     ~20
         23    > > JMPZ                                                     ~19, ->31
    9    24    >   FETCH_THIS                                       $21     
         25        INIT_METHOD_CALL                                         $21, 'arrayToXml'
         26        SEND_VAR_EX                                              !2
         27        SEND_VAR_EX                                              !4
         28        SEND_VAR_EX                                              !3
         29        DO_FCALL                                      0          
         30      > JMP                                                      ->41
   11    31    >   INIT_METHOD_CALL                                         !4, 'addChild'
         32        SEND_VAR_EX                                              !3
         33        DO_FCALL                                      0  $23     
         34        ASSIGN                                                   !5, $23
   12    35        FETCH_THIS                                       $25     
         36        INIT_METHOD_CALL                                         $25, 'arrayToXml'
         37        SEND_VAR_EX                                              !2
         38        SEND_VAR_EX                                              !5
         39        SEND_VAR_EX                                              !3
         40        DO_FCALL                                      0          
         41    > > JMP                                                      ->52
   15    42    >   INIT_METHOD_CALL                                         !4, 'addChild'
         43        SEND_VAR_EX                                              !6
         44        DO_FCALL                                      0  $27     
         45        ASSIGN                                                   !5, $27
   16    46        FETCH_THIS                                       $29     
         47        INIT_METHOD_CALL                                         $29, 'arrayToXml'
         48        SEND_VAR_EX                                              !2
         49        SEND_VAR_EX                                              !5
         50        SEND_VAR_EX                                              !6
         51        DO_FCALL                                      0          
         52    > > JMP                                                      ->108
   19    53    >   INIT_FCALL                                               'is_numeric'
         54        SEND_VAR                                                 !3
         55        DO_ICALL                                         $31     
         56        BOOL_NOT                                         ~32     $31
         57      > JMPZ                                                     ~32, ->100
   20    58    >   INIT_FCALL                                               'substr'
         59        SEND_VAR                                                 !3
         60        SEND_VAL                                                 0
         61        SEND_VAL                                                 1
         62        DO_ICALL                                         $33     
         63        IS_IDENTICAL                                             $33, '%40'
         64      > JMPZ                                                     ~34, ->74
   21    65    >   INIT_METHOD_CALL                                         !4, 'addAttribute'
         66        INIT_FCALL                                               'substr'
         67        SEND_VAR                                                 !3
         68        SEND_VAL                                                 1
         69        DO_ICALL                                         $35     
         70        SEND_VAR_NO_REF_EX                                       $35
         71        SEND_VAR_EX                                              !2
         72        DO_FCALL                                      0          
         73      > JMP                                                      ->99
   22    74    >   IS_IDENTICAL                                     ~37     !3, 'value'
         75      > JMPZ_EX                                          ~37     ~37, ->79
         76    >   COUNT                                            ~38     !0
         77        IS_IDENTICAL                                     ~39     ~38, 1
         78        BOOL                                             ~37     ~39
         79    > > JMPZ                                                     ~37, ->83
   23    80    >   ASSIGN_OBJ                                               !4, '0'
         81        OP_DATA                                                  !2
         82      > JMP                                                      ->99
   24    83    >   TYPE_CHECK                                   12          !2
         84      > JMPZ                                                     ~41, ->91
   25    85    >   INIT_METHOD_CALL                                         !4, 'addChild'
         86        SEND_VAR_EX                                              !3
         87        CAST                                          4  ~42     !2
         88        SEND_VAL_EX                                              ~42
         89        DO_FCALL                                      0          
         90      > JMP                                                      ->99
   27    91    >   INIT_METHOD_CALL                                         !4, 'addChild'
         92        SEND_VAR_EX                                              !3
         93        INIT_FCALL                                               'htmlspecialchars'
         94        SEND_VAR                                                 !2
         95        SEND_VAL                                                 3
         96        DO_ICALL                                         $44     
         97        SEND_VAR_NO_REF_EX                                       $44
         98        DO_FCALL                                      0          
         99    > > JMP                                                      ->108
   30   100    >   INIT_METHOD_CALL                                         !4, 'addChild'
        101        SEND_VAR_EX                                              !6
        102        INIT_FCALL                                               'htmlspecialchars'
        103        SEND_VAR                                                 !2
        104        SEND_VAL                                                 3
        105        DO_ICALL                                         $46     
        106        SEND_VAR_NO_REF_EX                                       $46
        107        DO_FCALL                                      0          
    5   108    > > JMP                                                      ->6
        109    >   FE_FREE                                                  $11
   35   110        FETCH_OBJ_R                                      ~48     !1, 'x'
        111        ECHO                                                     ~48
   37   112      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
192.47 ms | 1404 KiB | 19 Q