3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myData = [ 'config' => [ 'google' => [ 'api' => [ 'key'=> 'secret', ] ] ] ]; echo dotToIndex($myData, "config.google.api.key"); function dotToIndex($array, $string) { $parts = explode('.', $string); $element = $array; foreach ($parts as $part) { $element = $element[$part]; } return $element; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uAROF
function name:  (null)
number of ops:  7
compiled vars:  !0 = $myData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL_BY_NAME                                       'dotToIndex'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              'config.google.api.key'
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
   22     6      > RETURN                                                   1

Function dottoindex:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/uAROF
function name:  dotToIndex
number of ops:  16
compiled vars:  !0 = $array, !1 = $string, !2 = $parts, !3 = $element, !4 = $part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '.'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
   17     7        ASSIGN                                                   !3, !0
   18     8      > FE_RESET_R                                       $8      !2, ->13
          9    > > FE_FETCH_R                                               $8, !4, ->13
   19    10    >   FETCH_DIM_R                                      ~9      !3, !4
         11        ASSIGN                                                   !3, ~9
   18    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $8
   21    14      > RETURN                                                   !3
   22    15*     > RETURN                                                   null

End of function dottoindex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.71 ms | 1003 KiB | 14 Q