3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getValue($testArray, $exploded, $index) { if(is_array($testArray[$exploded[$index]])) { return getValue($testArray[$exploded[$index]], $exploded, $index++); } else { return $testArray[$exploded[$index]]; } } $string = 'router.format'; $testArray = array( 'router' => array( 'format' => 'xml', ), ); $exploded = explode(".", $string); /*if(count($exploded) != count($testArray)) { throw new Exception("mismatch"); }*/ $desiredValue = getValue($testArray, $exploded, 0); print_r($desiredValue);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1Jm14
function name:  (null)
number of ops:  17
compiled vars:  !0 = $string, !1 = $testArray, !2 = $exploded, !3 = $desiredValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 'router.format'
   16     1        ASSIGN                                                   !1, <array>
   22     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '.'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   29     7        INIT_FCALL                                               'getvalue'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 0
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !3, $8
   31    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function getvalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1Jm14
function name:  getValue
number of ops:  22
compiled vars:  !0 = $testArray, !1 = $exploded, !2 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        FETCH_DIM_R                                      ~3      !1, !2
          4        FETCH_DIM_R                                      ~4      !0, ~3
          5        TYPE_CHECK                                  128          ~4
          6      > JMPZ                                                     ~5, ->18
    7     7    >   INIT_FCALL_BY_NAME                                       'getValue'
          8        CHECK_FUNC_ARG                                           
          9        FETCH_DIM_R                                      ~6      !1, !2
         10        FETCH_DIM_FUNC_ARG                               $7      !0, ~6
         11        SEND_FUNC_ARG                                            $7
         12        SEND_VAR_EX                                              !1
         13        POST_INC                                         ~8      !2
         14        SEND_VAL_EX                                              ~8
         15        DO_FCALL                                      0  $9      
         16      > RETURN                                                   $9
         17*       JMP                                                      ->21
   11    18    >   FETCH_DIM_R                                      ~10     !1, !2
         19        FETCH_DIM_R                                      ~11     !0, ~10
         20      > RETURN                                                   ~11
   13    21*     > RETURN                                                   null

End of function getvalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.07 ms | 1403 KiB | 18 Q