3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = []; $result["store"]["this"]["here"] = "test"; $key = "[store][this][here]"; // some housekeeping $keyArr = explode("][", $key); $keyArr[0] = trim($keyArr[0], "["); $keyArr[count($keyArr) - 1] = trim($keyArr[count($keyArr) - 1], "]"); $res = $result; foreach ($keyArr as $key) { if (isset($res[$key])) { $res = $res[$key]; } } var_dump($res); // test
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 36
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/kLHh8
function name:  (null)
number of ops:  42
compiled vars:  !0 = $result, !1 = $key, !2 = $keyArr, !3 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        FETCH_DIM_W                                      $5      !0, 'store'
          2        FETCH_DIM_W                                      $6      $5, 'this'
          3        ASSIGN_DIM                                               $6, 'here'
          4        OP_DATA                                                  'test'
    5     5        ASSIGN                                                   !1, '%5Bstore%5D%5Bthis%5D%5Bhere%5D'
    8     6        INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '%5D%5B'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !2, $9
    9    11        INIT_FCALL                                               'trim'
         12        FETCH_DIM_R                                      ~12     !2, 0
         13        SEND_VAL                                                 ~12
         14        SEND_VAL                                                 '%5B'
         15        DO_ICALL                                         $13     
         16        ASSIGN_DIM                                               !2, 0
         17        OP_DATA                                                  $13
   10    18        COUNT                                            ~14     !2
         19        SUB                                              ~15     ~14, 1
         20        INIT_FCALL                                               'trim'
         21        COUNT                                            ~17     !2
         22        SUB                                              ~18     ~17, 1
         23        FETCH_DIM_R                                      ~19     !2, ~18
         24        SEND_VAL                                                 ~19
         25        SEND_VAL                                                 '%5D'
         26        DO_ICALL                                         $20     
         27        ASSIGN_DIM                                               !2, ~15
         28        OP_DATA                                                  $20
   11    29        ASSIGN                                                   !3, !0
   12    30      > FE_RESET_R                                       $22     !2, ->37
         31    > > FE_FETCH_R                                               $22, !1, ->37
   13    32    >   ISSET_ISEMPTY_DIM_OBJ                         0          !3, !1
         33      > JMPZ                                                     ~23, ->36
   14    34    >   FETCH_DIM_R                                      ~24     !3, !1
         35        ASSIGN                                                   !3, ~24
   12    36    > > JMP                                                      ->31
         37    >   FE_FREE                                                  $22
   17    38        INIT_FCALL                                               'var_dump'
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.21 ms | 1090 KiB | 17 Q