3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( "FL_1" => array( "MIC_1" => array( "SP_4" => 7 ), "MIC_13" => array( "SP_16" => 4 ), "MIC_6" => array( "SP_74" => 4 ) ), "FL_2" => array( "MIC_1" => array( "SP_5" => 4 ), "MIC_13" => array( "SP_17" => 4 ), "MIC_6" => array( "SP_75" => 4 ) ), "FL_3" => array( "MIC_1" => array( "SP_5" => 89 ), "MIC_13" => array( "SP_18" => 1 ), "MIC_6" => array( "SP_78" => 21 ) ) ); // find the minimum SP_X value and its key $min_sp = PHP_INT_MAX; $min_key = ''; array_walk_recursive($array, function ($v, $k) use (&$min_sp, &$min_key) { if ($v < $min_sp) { $min_sp = $v; $min_key = $k; } }); echo "$min_key => $min_sp\n"; // find the MIC_X key corresponding to the min SP_X value $mic_key = ''; foreach ($array as $fl) { foreach ($fl as $mic => $sp) { if (isset($sp[$min_key]) && $sp[$min_key] == $min_sp) { $mic_key = $mic; break 2; } } } echo "$mic_key\n"; // filter the array to get all the MIC_X values $out = array_map(function ($fl) use ($mic_key) { return array_filter($fl, function ($mic) use ($mic_key) { return $mic == $mic_key; }, ARRAY_FILTER_USE_KEY); }, $array); print_r($out);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 33
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 33
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 31
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 31
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 31
Branch analysis from position: 33
Branch analysis from position: 33
filename:       /in/pIoMK
function name:  (null)
number of ops:  48
compiled vars:  !0 = $array, !1 = $min_sp, !2 = $min_key, !3 = $mic_key, !4 = $fl, !5 = $sp, !6 = $mic, !7 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   40     1        ASSIGN                                                   !1, 9223372036854775807
   41     2        ASSIGN                                                   !2, ''
   42     3        INIT_FCALL                                               'array_walk_recursive'
          4        SEND_REF                                                 !0
          5        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
          6        BIND_LEXICAL                                             ~11, !1
          7        BIND_LEXICAL                                             ~11, !2
   47     8        SEND_VAL                                                 ~11
   42     9        DO_ICALL                                                 
   48    10        ROPE_INIT                                     4  ~14     !2
         11        ROPE_ADD                                      1  ~14     ~14, '+%3D%3E+'
         12        ROPE_ADD                                      2  ~14     ~14, !1
         13        ROPE_END                                      3  ~13     ~14, '%0A'
         14        ECHO                                                     ~13
   51    15        ASSIGN                                                   !3, ''
   52    16      > FE_RESET_R                                       $17     !0, ->33
         17    > > FE_FETCH_R                                               $17, !4, ->33
   53    18    > > FE_RESET_R                                       $18     !4, ->31
         19    > > FE_FETCH_R                                       ~19     $18, !5, ->31
         20    >   ASSIGN                                                   !6, ~19
   54    21        ISSET_ISEMPTY_DIM_OBJ                         0  ~21     !5, !2
         22      > JMPZ_EX                                          ~21     ~21, ->26
         23    >   FETCH_DIM_R                                      ~22     !5, !2
         24        IS_EQUAL                                         ~23     !1, ~22
         25        BOOL                                             ~21     ~23
         26    > > JMPZ                                                     ~21, ->30
   55    27    >   ASSIGN                                                   !3, !6
   56    28        FE_FREE                                                  $18
         29      > JMP                                                      ->33
   53    30    > > JMP                                                      ->19
         31    >   FE_FREE                                                  $18
   52    32      > JMP                                                      ->17
         33    >   FE_FREE                                                  $17
   60    34        NOP                                                      
         35        FAST_CONCAT                                      ~25     !3, '%0A'
         36        ECHO                                                     ~25
   63    37        INIT_FCALL                                               'array_map'
         38        DECLARE_LAMBDA_FUNCTION                          ~26     [1]
         39        BIND_LEXICAL                                             ~26, !3
   67    40        SEND_VAL                                                 ~26
         41        SEND_VAR                                                 !0
   63    42        DO_ICALL                                         $27     
         43        ASSIGN                                                   !7, $27
   69    44        INIT_FCALL                                               'print_r'
         45        SEND_VAR                                                 !7
         46        DO_ICALL                                                 
         47      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/pIoMK
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $v, !1 = $k, !2 = $min_sp, !3 = $min_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
   43     4        IS_SMALLER                                               !0, !2
          5      > JMPZ                                                     ~4, ->8
   44     6    >   ASSIGN                                                   !2, !0
   45     7        ASSIGN                                                   !3, !1
   47     8    > > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pIoMK
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $fl, !1 = $mic_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   64     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          5        BIND_LEXICAL                                             ~2, !1
   66     6        SEND_VAL                                                 ~2
          7        SEND_VAL                                                 2
   64     8        DO_ICALL                                         $3      
   66     9      > RETURN                                                   $3
   67    10*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pIoMK
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $mic, !1 = $mic_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   65     2        IS_EQUAL                                         ~2      !0, !1
          3      > RETURN                                                   ~2
   66     4*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.84 ms | 1465 KiB | 17 Q