3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr['data_|_multilanguage_|_en_|_field'] = 23; $arr['data_|_multilanguage_|_de_|_field'] = 27; $delimiter = '_|_'; $result = array_reduce(array_keys($arr), function(&$c, $x) use ($delimiter, $arr) { $ref = &$c; foreach(explode($delimiter, $x) as $field) { $ref = &$ref[$field]; } $ref = $arr[$x]; return $c; }, []); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vlAOF
function name:  (null)
number of ops:  21
compiled vars:  !0 = $arr, !1 = $delimiter, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN_DIM                                               !0, 'data_%7C_multilanguage_%7C_en_%7C_field'
          1        OP_DATA                                                  23
    4     2        ASSIGN_DIM                                               !0, 'data_%7C_multilanguage_%7C_de_%7C_field'
          3        OP_DATA                                                  27
    6     4        ASSIGN                                                   !1, '_%7C_'
    8     5        INIT_FCALL                                               'array_reduce'
          6        INIT_FCALL                                               'array_keys'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $6      
          9        SEND_VAR                                                 $6
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvlAOF%3A8%240'
         11        BIND_LEXICAL                                             ~7, !1
         12        BIND_LEXICAL                                             ~7, !0
   17    13        SEND_VAL                                                 ~7
         14        SEND_VAL                                                 <array>
         15        DO_ICALL                                         $8      
    8    16        ASSIGN                                                   !2, $8
   19    17        INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvlAOF%3A8%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/vlAOF
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $c, !1 = $x, !2 = $delimiter, !3 = $arr, !4 = $ref, !5 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   10     4        ASSIGN_REF                                               !4, !0
   11     5        INIT_FCALL                                               'explode'
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9      > FE_RESET_R                                       $8      $7, ->14
         10    > > FE_FETCH_R                                               $8, !5, ->14
   13    11    >   FETCH_DIM_W                                      $9      !4, !5
         12        ASSIGN_REF                                               !4, $9
   11    13      > JMP                                                      ->10
         14    >   FE_FREE                                                  $8
   15    15        FETCH_DIM_R                                      ~11     !3, !1
         16        ASSIGN                                                   !4, ~11
   16    17      > RETURN                                                   !0
   17    18*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvlAOF%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.43 ms | 1400 KiB | 21 Q