3v4l.org

run code in 300+ PHP versions simultaneously
<?php function setKey($session_keys, $value) { $current_key = ''; $counter = 0; $prev_step = $_SESSION; try { $session_keys_array = explode(':', $session_keys); krsort($session_keys_array); $c = count($session_keys_array); $count = 0; $arr = array(); foreach ($session_keys_array as $key) { $count++; switch ($count) { case 1: $arr[$key] = $value; break; case ($count > 1 AND $count < $c): $arr[$key] = $arr; break; case $c: $_SESSION[$key] = $arr; break; } } } catch (Exception $e) { //TODO:log notice if Session[currentKey] is not an array return false; } return array_key_exists($key,$prev_step) && eval('!empty($_SESSION' . $current_key . ');'); } $_SESSION['1']['2']['3'] = 'zzzz'; setKey('1:2:3', 77); echo $_SESSION['1']['2']['3']; print_f($_SESSION);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/srZoI
function name:  (null)
number of ops:  20
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   FETCH_W                      global              $0      '_SESSION'
          1        FETCH_DIM_W                                      $1      $0, 1
          2        FETCH_DIM_W                                      $2      $1, 2
          3        ASSIGN_DIM                                               $2, 3
          4        OP_DATA                                                  'zzzz'
   41     5        INIT_FCALL                                               'setkey'
          6        SEND_VAL                                                 '1%3A2%3A3'
          7        SEND_VAL                                                 77
          8        DO_FCALL                                      0          
   43     9        FETCH_R                      global              ~5      '_SESSION'
         10        FETCH_DIM_R                                      ~6      ~5, 1
         11        FETCH_DIM_R                                      ~7      ~6, 2
         12        FETCH_DIM_R                                      ~8      ~7, 3
         13        ECHO                                                     ~8
   44    14        INIT_FCALL_BY_NAME                                       'print_f'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_FUNC_ARG               global              $9      '_SESSION'
         17        SEND_FUNC_ARG                                            $9
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Function setkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 44
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 44
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 32
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 35
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 39
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 27
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 54
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 44
Found catch point at position: 46
Branch analysis from position: 46
2 jumps found. (Code = 107) Position 1 = 47, Position 2 = -2
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/srZoI
function name:  setKey
number of ops:  56
compiled vars:  !0 = $session_keys, !1 = $value, !2 = $current_key, !3 = $counter, !4 = $prev_step, !5 = $session_keys_array, !6 = $c, !7 = $count, !8 = $arr, !9 = $key, !10 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, ''
    5     3        ASSIGN                                                   !3, 0
    6     4        FETCH_R                      global              ~13     '_SESSION'
          5        ASSIGN                                                   !4, ~13
    9     6        INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '%3A'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $15     
         10        ASSIGN                                                   !5, $15
   11    11        INIT_FCALL                                               'krsort'
         12        SEND_REF                                                 !5
         13        DO_ICALL                                                 
   12    14        COUNT                                            ~18     !5
         15        ASSIGN                                                   !6, ~18
   13    16        ASSIGN                                                   !7, 0
   14    17        ASSIGN                                                   !8, <array>
   15    18      > FE_RESET_R                                       $22     !5, ->44
         19    > > FE_FETCH_R                                               $22, !9, ->44
   16    20    >   PRE_INC                                                  !7
   19    21        IS_EQUAL                                                 !7, 1
         22      > JMPNZ                                                    ~24, ->32
   22    23    >   IS_SMALLER                                       ~25     1, !7
         24      > JMPZ_EX                                          ~25     ~25, ->27
         25    >   IS_SMALLER                                       ~26     !7, !6
         26        BOOL                                             ~25     ~26
         27    >   IS_EQUAL                                                 !7, ~25
         28      > JMPNZ                                                    ~24, ->35
   25    29    >   IS_EQUAL                                                 !7, !6
         30      > JMPNZ                                                    ~24, ->39
         31    > > JMP                                                      ->43
   20    32    >   ASSIGN_DIM                                               !8, !9
         33        OP_DATA                                                  !1
   21    34      > JMP                                                      ->43
   23    35    >   QM_ASSIGN                                        ~29     !8
         36        ASSIGN_DIM                                               !8, !9
         37        OP_DATA                                                  ~29
   24    38      > JMP                                                      ->43
   26    39    >   FETCH_W                      global              $30     '_SESSION'
         40        ASSIGN_DIM                                               $30, !9
         41        OP_DATA                                                  !8
   27    42      > JMP                                                      ->43
   15    43    > > JMP                                                      ->19
         44    >   FE_FREE                                                  $22
         45      > JMP                                                      ->48
   31    46  E > > CATCH                                       last         'Exception'
   33    47    > > RETURN                                                   <false>
   36    48    >   ARRAY_KEY_EXISTS                                 ~32     !9, !4
         49      > JMPZ_EX                                          ~32     ~32, ->54
         50    >   CONCAT                                           ~33     '%21empty%28%24_SESSION', !2
         51        CONCAT                                           ~34     ~33, '%29%3B'
         52        INCLUDE_OR_EVAL                                  $35     ~34, EVAL
         53        BOOL                                             ~32     $35
         54    > > RETURN                                                   ~32
   37    55*     > RETURN                                                   null

End of function setkey

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.49 ms | 1407 KiB | 18 Q