3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ 1 => "tenants", 2 => "modules", ]; $array2 = [ "child" => [ "prefix" => "tenants", "slug" => "tenants", "child" => [ [ "prefix" => "modules/{id}", "slug" => "modules" ], [ "prefix" => "fetch/{id}", "slug" => "fetch" ], ], ], ]; $res = []; $result =[]; foreach ($array1 as $asd) { array_walk_recursive($array2['child'], function ($item, $key) use (&$result, &$res, &$asd) { if ($key == "slug") { if ($item == $asd) { $res[] = $item; } } if ($key == 'prefix') { $result[] = $item; } }); } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/E18Uq
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array1, !1 = $array2, !2 = $res, !3 = $result, !4 = $asd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   25     2        ASSIGN                                                   !2, <array>
   26     3        ASSIGN                                                   !3, <array>
   28     4      > FE_RESET_R                                       $9      !0, ->16
          5    > > FE_FETCH_R                                               $9, !4, ->16
   29     6    >   INIT_FCALL                                               'array_walk_recursive'
          7        FETCH_DIM_W                                      $10     !1, 'child'
          8        SEND_REF                                                 $10
   30     9        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
         10        BIND_LEXICAL                                             ~11, !3
         11        BIND_LEXICAL                                             ~11, !2
         12        BIND_LEXICAL                                             ~11, !4
   42    13        SEND_VAL                                                 ~11
   29    14        DO_ICALL                                                 
   28    15      > JMP                                                      ->5
         16    >   FE_FREE                                                  $9
   45    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                                 
         20      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 11
Branch analysis from position: 11
filename:       /in/E18Uq
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $item, !1 = $key, !2 = $result, !3 = $res, !4 = $asd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
          4        BIND_STATIC                                              !4
   32     5        IS_EQUAL                                                 !1, 'slug'
          6      > JMPZ                                                     ~5, ->11
   33     7    >   IS_EQUAL                                                 !0, !4
          8      > JMPZ                                                     ~6, ->11
   34     9    >   ASSIGN_DIM                                               !3
         10        OP_DATA                                                  !0
   38    11    >   IS_EQUAL                                                 !1, 'prefix'
         12      > JMPZ                                                     ~8, ->15
   39    13    >   ASSIGN_DIM                                               !2
         14        OP_DATA                                                  !0
   42    15    > > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
198.4 ms | 1006 KiB | 15 Q