3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = array( 'Europe' => 'World', 'Asia' => 'World', 'Africa' => 'World', 'France' => 'Europe', 'Poland' => 'Europe', 'Germany' => 'Europe', 'Paris' => 'France', 'Lille' => 'France', 'Warsaw' => 'Poland', 'Szczecin' => 'Poland', 'Berlin' => 'Germany', 'Gumience' => 'Szczecin' ); $x = new SimpleXMLElement ("<root/>"); foreach ($myArray as $child => $parent) { if (!$x->xpath ("//$parent")) { $x->addChild($parent); } $x->xpath ("//$parent")[0]->addChild($child); } $json = json_encode($x); $array = json_decode($json,TRUE); var_export ($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 28
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 18
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/fenJ6
function name:  (null)
number of ops:  42
compiled vars:  !0 = $myArray, !1 = $x, !2 = $parent, !3 = $child, !4 = $json, !5 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   19     1        NEW                                              $7      'SimpleXMLElement'
          2        SEND_VAL_EX                                              '%3Croot%2F%3E'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $7
   20     5      > FE_RESET_R                                       $10     !0, ->28
          6    > > FE_FETCH_R                                       ~11     $10, !2, ->28
          7    >   ASSIGN                                                   !3, ~11
   22     8        INIT_METHOD_CALL                                         !1, 'xpath'
          9        NOP                                                      
         10        FAST_CONCAT                                      ~13     '%2F%2F', !2
         11        SEND_VAL_EX                                              ~13
         12        DO_FCALL                                      0  $14     
         13        BOOL_NOT                                         ~15     $14
         14      > JMPZ                                                     ~15, ->18
   24    15    >   INIT_METHOD_CALL                                         !1, 'addChild'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
   26    18    >   INIT_METHOD_CALL                                         !1, 'xpath'
         19        NOP                                                      
         20        FAST_CONCAT                                      ~17     '%2F%2F', !2
         21        SEND_VAL_EX                                              ~17
         22        DO_FCALL                                      0  $18     
         23        FETCH_DIM_R                                      ~19     $18, 0
         24        INIT_METHOD_CALL                                         ~19, 'addChild'
         25        SEND_VAR_EX                                              !3
         26        DO_FCALL                                      0          
   20    27      > JMP                                                      ->6
         28    >   FE_FREE                                                  $10
   28    29        INIT_FCALL                                               'json_encode'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $21     
         32        ASSIGN                                                   !4, $21
   29    33        INIT_FCALL                                               'json_decode'
         34        SEND_VAR                                                 !4
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $23     
         37        ASSIGN                                                   !5, $23
   30    38        INIT_FCALL                                               'var_export'
         39        SEND_VAR                                                 !5
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.1 ms | 1392 KiB | 19 Q