3v4l.org

run code in 500+ PHP versions simultaneously
<?php $user = [ 'profile' => [ 'authkey' => '', 'publickey' => '', 'status' => 19 ], 'setup' => [ 'profile' => false, 'contact' => false, 'payments' => false, 'subscription' => false ], 'paygateway' => [ 'paypal' => [ 'publickey' =>'', 'secretkey' => '', 'testarray' => [ 'key1' => 'value1', 'key2' => 'value2', 'key3' => [ 'key4' => 'level4' ] ], 'webhookid' => '' ], 'stripe' => [ 'publickey' => '', 'secretkey' => '' ] ] ]; function buildKeyPath(array $array, string $path): array { $result = []; foreach ($array as $key => $value) { if (is_array($value)) { array_push($result, ...buildKeyPath($value, "{$path}[$key]")); } else { $result[] = "{$path}[$key]"; } } return $result; } foreach ($user as $k => &$v) { $v = buildKeyPath($v, "[$k]"); } var_export($user);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 13
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/cRJ6m
function name:  (null)
number of ops:  18
compiled vars:  !0 = $user, !1 = $v, !2 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   48     1      > FE_RESET_RW                                          $4      !0, ->13
          2    > > FE_FETCH_RW                                          ~5      $4, !1, ->13
          3    >   ASSIGN                                                       !2, ~5
   49     4        INIT_FCALL                                                   'buildkeypath'
          5        SEND_VAR                                                     !1
          6        ROPE_INIT                                         3  ~8      '%5B'
          7        ROPE_ADD                                          1  ~8      ~8, !2
          8        ROPE_END                                          2  ~7      ~8, '%5D'
          9        SEND_VAL                                                     ~7
         10        DO_FCALL                                          0  $10     
         11        ASSIGN                                                       !1, $10
   48    12      > JMP                                                          ->2
         13    >   FE_FREE                                                      $4
   51    14        INIT_FCALL                                                   'var_export'
         15        SEND_VAR                                                     !0
         16        DO_ICALL                                                     
         17      > RETURN                                                       1

Function buildkeypath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 22
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/cRJ6m
function name:  buildKeyPath
number of ops:  34
compiled vars:  !0 = $array, !1 = $path, !2 = $result, !3 = $value, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   37     2        ASSIGN                                                       !2, <array>
   38     3      > FE_RESET_R                                           $6      !0, ->29
          4    > > FE_FETCH_R                                           ~7      $6, !3, ->29
          5    >   ASSIGN                                                       !4, ~7
   39     6        TYPE_CHECK                                      128          !3
          7      > JMPZ                                                         ~9, ->22
   40     8    >   INIT_FCALL                                                   'array_push'
          9        SEND_REF                                                     !2
         10        INIT_FCALL_BY_NAME                                           'buildKeyPath'
         11        SEND_VAR_EX                                                  !3
         12        ROPE_INIT                                         4  ~11     !1
         13        ROPE_ADD                                          1  ~11     ~11, '%5B'
         14        ROPE_ADD                                          2  ~11     ~11, !4
         15        ROPE_END                                          3  ~10     ~11, '%5D'
         16        SEND_VAL_EX                                                  ~10
         17        DO_FCALL                                          0  $13     
         18        SEND_UNPACK                                                  $13
         19        CHECK_UNDEF_ARGS                                             
         20        DO_ICALL                                                     
   39    21      > JMP                                                          ->28
   42    22    >   ROPE_INIT                                         4  ~17     !1
         23        ROPE_ADD                                          1  ~17     ~17, '%5B'
         24        ROPE_ADD                                          2  ~17     ~17, !4
         25        ROPE_END                                          3  ~16     ~17, '%5D'
         26        ASSIGN_DIM                                                   !2
         27        OP_DATA                                                      ~16
   38    28    > > JMP                                                          ->4
         29    >   FE_FREE                                                      $6
   45    30        VERIFY_RETURN_TYPE                                           !2
         31      > RETURN                                                       !2
   46    32*       VERIFY_RETURN_TYPE                                           
         33*     > RETURN                                                       null

End of function buildkeypath

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.83 ms | 1991 KiB | 16 Q