3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = <<<DATA Main{ NetworkAccess 1; MaxCPE 6; MaxClassifiers 20; GlobalPrivacyEnable 1; BaselinePrivacy{ AuthTimeout 10; ReAuthTimeout 10; AuthGraceTime 600; OperTimeout 10; ReKeyTimeout 10; TEKGraceTime 600; AuthRejectTimeout 60; SAMapWaitTimeout 1; SAMapMaxRetries 4; } UsServiceFlow{ UsServiceFlowRef 1; QosParamSetType 7; TrafficPriority 2; MaxRateSustained 1000000; SchedulingType 2; MaxTrafficBurst 8000; MaxConcatenatedBurst 8000; } DsServiceFlow{ DsServiceFlowRef 101; QosParamSetType 7; TrafficPriority 2; MaxRateSustained 10000000; } } DATA; function processItems($items, &$current, &$parent) { $item = trim(array_shift($items)); if ($item) { if (substr($item, -1) === '{') { $key = rtrim($item, '{'); $current[$key] = []; processItems($items, $current[$key], $parent); return; } if (trim($item) === '}') { processItems($items, $parent, $parent); return; } $parts = explode(' ', $item); $current[$parts[0]] = rtrim($parts[1], ';'); processItems($items, $current, $parent); } } $curr = []; processItems(explode("\n", $data), $curr, $curr); print_r($curr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2XmSV
function name:  (null)
number of ops:  15
compiled vars:  !0 = $data, !1 = $curr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Main%7B%0A++NetworkAccess+1%3B+%0A++MaxCPE+6%3B+%0A++MaxClassifiers+20%3B+%0A++GlobalPrivacyEnable+1%3B+%0A++BaselinePrivacy%7B%0A++++AuthTimeout+10%3B+%0A++++ReAuthTimeout+10%3B+%0A++++AuthGraceTime+600%3B+%0A++++OperTimeout+10%3B+%0A++++ReKeyTimeout+10%3B+%0A++++TEKGraceTime+600%3B+%0A++++AuthRejectTimeout+60%3B+%0A++++SAMapWaitTimeout+1%3B+%0A++++SAMapMaxRetries+4%3B+%0A++%7D%0A++UsServiceFlow%7B%0A++++UsServiceFlowRef+1%3B+%0A++++QosParamSetType+7%3B+%0A++++TrafficPriority+2%3B+%0A++++MaxRateSustained+1000000%3B+%0A++++SchedulingType+2%3B+%0A++++MaxTrafficBurst+8000%3B+%0A++++MaxConcatenatedBurst+8000%3B+%0A++%7D%0A++DsServiceFlow%7B%0A++++DsServiceFlowRef+101%3B+%0A++++QosParamSetType+7%3B+%0A++++TrafficPriority+2%3B+%0A++++MaxRateSustained+10000000%3B+%0A++%7D%0A%7D'
   61     1        ASSIGN                                                   !1, <array>
   62     2        INIT_FCALL                                               'processitems'
          3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '%0A'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
          8        SEND_REF                                                 !1
          9        SEND_REF                                                 !1
         10        DO_FCALL                                      0          
   64    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function processitems:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 61
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 32
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
filename:       /in/2XmSV
function name:  processItems
number of ops:  62
compiled vars:  !0 = $items, !1 = $current, !2 = $parent, !3 = $item, !4 = $key, !5 = $parts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   39     3        INIT_FCALL                                               'trim'
          4        INIT_FCALL                                               'array_shift'
          5        SEND_REF                                                 !0
          6        DO_ICALL                                         $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !3, $7
   40    10      > JMPZ                                                     !3, ->61
   42    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !3
         13        SEND_VAL                                                 -1
         14        DO_ICALL                                         $9      
         15        IS_IDENTICAL                                             $9, '%7B'
         16      > JMPZ                                                     ~10, ->32
   43    17    >   INIT_FCALL                                               'rtrim'
         18        SEND_VAR                                                 !3
         19        SEND_VAL                                                 '%7B'
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !4, $11
   44    22        ASSIGN_DIM                                               !1, !4
         23        OP_DATA                                                  <array>
   45    24        INIT_FCALL_BY_NAME                                       'processItems'
         25        SEND_VAR_EX                                              !0
         26        CHECK_FUNC_ARG                                           
         27        FETCH_DIM_FUNC_ARG                               $14     !1, !4
         28        SEND_FUNC_ARG                                            $14
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0          
   46    31      > RETURN                                                   null
   49    32    >   INIT_FCALL                                               'trim'
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                         $16     
         35        IS_IDENTICAL                                             $16, '%7D'
         36      > JMPZ                                                     ~17, ->43
   50    37    >   INIT_FCALL_BY_NAME                                       'processItems'
         38        SEND_VAR_EX                                              !0
         39        SEND_VAR_EX                                              !2
         40        SEND_VAR_EX                                              !2
         41        DO_FCALL                                      0          
   51    42      > RETURN                                                   null
   54    43    >   INIT_FCALL                                               'explode'
         44        SEND_VAL                                                 '+'
         45        SEND_VAR                                                 !3
         46        DO_ICALL                                         $19     
         47        ASSIGN                                                   !5, $19
   55    48        FETCH_DIM_R                                      ~21     !5, 0
         49        INIT_FCALL                                               'rtrim'
         50        FETCH_DIM_R                                      ~23     !5, 1
         51        SEND_VAL                                                 ~23
         52        SEND_VAL                                                 '%3B'
         53        DO_ICALL                                         $24     
         54        ASSIGN_DIM                                               !1, ~21
         55        OP_DATA                                                  $24
   57    56        INIT_FCALL_BY_NAME                                       'processItems'
         57        SEND_VAR_EX                                              !0
         58        SEND_VAR_EX                                              !1
         59        SEND_VAR_EX                                              !2
         60        DO_FCALL                                      0          
   59    61    > > RETURN                                                   null

End of function processitems

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.55 ms | 1017 KiB | 20 Q