3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xml_encode($mixed, $domElement=null, $DOMDocument=null) { if (is_null($DOMDocument)) { $DOMDocument =new DOMDocument; $DOMDocument->formatOutput = true; xml_encode($mixed, $DOMDocument, $DOMDocument); echo $DOMDocument->saveXML(); } else { if (is_array($mixed)) { foreach ($mixed as $index => $mixedElement) { if (is_int($index)) { if ($index === 0) { $node = $domElement; } else { $node = $DOMDocument->createElement($domElement->tagName); $domElement->parentNode->appendChild($node); } } else { $plural = $DOMDocument->createElement($index); $domElement->appendChild($plural); $node = $plural; if (!(rtrim($index, 's') === $index)) { $singular = $DOMDocument->createElement(rtrim($index, 's')); $plural->appendChild($singular); $node = $singular; } } xml_encode($mixedElement, $node, $DOMDocument); } } else { $mixed = is_bool($mixed) ? ($mixed ? 'true' : 'false') : $mixed; $domElement->appendChild($DOMDocument->createTextNode($mixed)); } } } $str = xml_encode( array ( 'cry_shop' => array ( 'packs' => array ( 3 => array ( 'id' => 3, 'minLevel' => 1, 'elements' => array ( 'crystal' => array ( 'count' => 100, 'offer' => NULL, 'probability' => NULL, 'offerVal' => NULL, 'offerStartTime' => NULL, 'offerEndTime' => NULL, ), ), 'inapSystemName' => 'inap1', 'priceCraft' => array ( ), 'priceCrystal' => NULL, 'crystalOffer' => NULL, 'crystalOfferVal' => NULL, 'crystalOfferStartTime' => NULL, 'crystalOfferEndTime' => NULL, 'translationTitle' => NULL, 'translationDescription' => NULL, ), ), 'translationTitle' => NULL, 'translationDescription' => NULL, ), 'gold_shop' => array ( 'packs' => array ( 2 => array ( 'id' => 2, 'minLevel' => 1, 'elements' => array ( 'gold' => array ( 'count' => 500, 'offer' => NULL, 'probability' => NULL, 'offerVal' => NULL, 'offerStartTime' => NULL, 'offerEndTime' => NULL, ), ), 'inapSystemName' => 'inap1', 'priceCraft' => array ( ), 'priceCrystal' => NULL, 'crystalOffer' => NULL, 'crystalOfferVal' => NULL, 'crystalOfferStartTime' => NULL, 'crystalOfferEndTime' => NULL, 'translationTitle' => NULL, 'translationDescription' => NULL, ), ), 'translationTitle' => NULL, 'translationDescription' => NULL, ), 'res_shop' => array ( 'packs' => array ( 1 => array ( 'id' => 1, 'minLevel' => 1, 'elements' => array ( 'wood' => array ( 'count' => 30, 'offer' => NULL, 'probability' => NULL, 'offerVal' => NULL, 'offerStartTime' => NULL, 'offerEndTime' => NULL, ), 'stone' => array ( 'count' => 50, 'offer' => NULL, 'probability' => NULL, 'offerVal' => NULL, 'offerStartTime' => NULL, 'offerEndTime' => NULL, ), ), 'inapSystemName' => NULL, 'priceCraft' => array ( ), 'priceCrystal' => NULL, 'crystalOffer' => NULL, 'crystalOfferVal' => NULL, 'crystalOfferStartTime' => NULL, 'crystalOfferEndTime' => NULL, 'translationTitle' => NULL, 'translationDescription' => NULL, ), ), 'translationTitle' => NULL, 'translationDescription' => NULL, ), 'util_shop' => array ( 'packs' => array ( 4 => array ( 'id' => 4, 'minLevel' => 0, 'elements' => array ( 'dropRequestCounter' => array ( 'count' => 1, 'offer' => NULL, 'probability' => NULL, 'offerVal' => NULL, 'offerStartTime' => NULL, 'offerEndTime' => NULL, ), ), 'inapSystemName' => NULL, 'priceCraft' => array ( ), 'priceCrystal' => 5, 'crystalOffer' => NULL, 'crystalOfferVal' => NULL, 'crystalOfferStartTime' => NULL, 'crystalOfferEndTime' => NULL, 'translationTitle' => NULL, 'translationDescription' => NULL, ), ), 'translationTitle' => NULL, 'translationDescription' => NULL, ), ) ); var_dump($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7SBOP
function name:  (null)
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_FCALL                                               'xml_encode'
   49     1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $1      
   42     3        ASSIGN                                                   !0, $1
  198     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function xml_encode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 92
Branch analysis from position: 92
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 76
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 74
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 74
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 41
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 68
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 68
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 92
Branch analysis from position: 92
Branch analysis from position: 74
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 84
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 81
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 84
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7SBOP
function name:  xml_encode
number of ops:  93
compiled vars:  !0 = $mixed, !1 = $domElement, !2 = $DOMDocument, !3 = $mixedElement, !4 = $index, !5 = $node, !6 = $plural, !7 = $singular
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
    3     3        TYPE_CHECK                                    2          !2
          4      > JMPZ                                                     ~8, ->19
    4     5    >   NEW                                              $9      'DOMDocument'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $9
    5     8        ASSIGN_OBJ                                               !2, 'formatOutput'
          9        OP_DATA                                                  <true>
    6    10        INIT_FCALL_BY_NAME                                       'xml_encode'
         11        SEND_VAR_EX                                              !0
         12        SEND_VAR_EX                                              !2
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
    7    15        INIT_METHOD_CALL                                         !2, 'saveXML'
         16        DO_FCALL                                      0  $14     
         17        ECHO                                                     $14
         18      > JMP                                                      ->92
   10    19    >   TYPE_CHECK                                  128          !0
         20      > JMPZ                                                     ~15, ->76
   11    21    > > FE_RESET_R                                       $16     !0, ->74
         22    > > FE_FETCH_R                                       ~17     $16, !3, ->74
         23    >   ASSIGN                                                   !4, ~17
   12    24        TYPE_CHECK                                   16          !4
         25      > JMPZ                                                     ~19, ->41
   13    26    >   IS_IDENTICAL                                             !4, 0
         27      > JMPZ                                                     ~20, ->30
   14    28    >   ASSIGN                                                   !5, !1
         29      > JMP                                                      ->40
   17    30    >   INIT_METHOD_CALL                                         !2, 'createElement'
         31        CHECK_FUNC_ARG                                           
         32        FETCH_OBJ_FUNC_ARG                               $22     !1, 'tagName'
         33        SEND_FUNC_ARG                                            $22
         34        DO_FCALL                                      0  $23     
         35        ASSIGN                                                   !5, $23
   18    36        FETCH_OBJ_R                                      ~25     !1, 'parentNode'
         37        INIT_METHOD_CALL                                         ~25, 'appendChild'
         38        SEND_VAR_EX                                              !5
         39        DO_FCALL                                      0          
         40    > > JMP                                                      ->68
   22    41    >   INIT_METHOD_CALL                                         !2, 'createElement'
         42        SEND_VAR_EX                                              !4
         43        DO_FCALL                                      0  $27     
         44        ASSIGN                                                   !6, $27
   23    45        INIT_METHOD_CALL                                         !1, 'appendChild'
         46        SEND_VAR_EX                                              !6
         47        DO_FCALL                                      0          
   24    48        ASSIGN                                                   !5, !6
   25    49        INIT_FCALL                                               'rtrim'
         50        SEND_VAR                                                 !4
         51        SEND_VAL                                                 's'
         52        DO_ICALL                                         $31     
         53        IS_IDENTICAL                                     ~32     !4, $31
         54        BOOL_NOT                                         ~33     ~32
         55      > JMPZ                                                     ~33, ->68
   26    56    >   INIT_METHOD_CALL                                         !2, 'createElement'
         57        INIT_FCALL                                               'rtrim'
         58        SEND_VAR                                                 !4
         59        SEND_VAL                                                 's'
         60        DO_ICALL                                         $34     
         61        SEND_VAR_NO_REF_EX                                       $34
         62        DO_FCALL                                      0  $35     
         63        ASSIGN                                                   !7, $35
   27    64        INIT_METHOD_CALL                                         !6, 'appendChild'
         65        SEND_VAR_EX                                              !7
         66        DO_FCALL                                      0          
   28    67        ASSIGN                                                   !5, !7
   32    68    >   INIT_FCALL_BY_NAME                                       'xml_encode'
         69        SEND_VAR_EX                                              !3
         70        SEND_VAR_EX                                              !5
         71        SEND_VAR_EX                                              !2
         72        DO_FCALL                                      0          
   11    73      > JMP                                                      ->22
         74    >   FE_FREE                                                  $16
         75      > JMP                                                      ->92
   36    76    >   TYPE_CHECK                                   12          !0
         77      > JMPZ                                                     ~40, ->84
         78    > > JMPZ                                                     !0, ->81
         79    >   QM_ASSIGN                                        ~41     'true'
         80      > JMP                                                      ->82
         81    >   QM_ASSIGN                                        ~41     'false'
         82    >   QM_ASSIGN                                        ~42     ~41
         83      > JMP                                                      ->85
         84    >   QM_ASSIGN                                        ~42     !0
         85    >   ASSIGN                                                   !0, ~42
   37    86        INIT_METHOD_CALL                                         !1, 'appendChild'
         87        INIT_METHOD_CALL                                         !2, 'createTextNode'
         88        SEND_VAR_EX                                              !0
         89        DO_FCALL                                      0  $44     
         90        SEND_VAR_NO_REF_EX                                       $44
         91        DO_FCALL                                      0          
   40    92    > > RETURN                                                   null

End of function xml_encode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.08 ms | 1407 KiB | 18 Q