3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ [1,3], [1,6], [7,8] ]; $available = [6=>0, 1=>1]; //product $result = array_reduce(array_slice($input, 1), function($c, $x) { return call_user_func_array('array_merge', array_map(function($y) use ($c) { return array_map(function($z) use ($y) { return array_merge((array)$z, (array)$y); }, $c); }, $x) ); }, current($input)); var_dump($result); //filter: $result = array_filter($result, function($tuple) use ($available) { foreach(array_count_values($tuple) as $value=>$count) { if(isset($available[$value]) && $available[$value]<$count) { return false; } } return true; }); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjY1T
function name:  (null)
number of ops:  30
compiled vars:  !0 = $input, !1 = $available, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'array_reduce'
          3        INIT_FCALL                                               'array_slice'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 1
          6        DO_ICALL                                         $5      
          7        SEND_VAR                                                 $5
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvjY1T%3A6%240'
   17     9        SEND_VAL                                                 ~6
         10        INIT_FCALL                                               'current'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                         $8      
    6    15        ASSIGN                                                   !2, $8
   18    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   20    19        INIT_FCALL                                               'array_filter'
         20        SEND_VAR                                                 !2
         21        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvjY1T%3A20%243'
         22        BIND_LEXICAL                                             ~11, !1
   30    23        SEND_VAL                                                 ~11
         24        DO_ICALL                                         $12     
   20    25        ASSIGN                                                   !2, $12
   31    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvjY1T%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjY1T
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $c, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INIT_FCALL                                               'array_merge'
    9     3        INIT_FCALL                                               'array_map'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvjY1T%3A9%241'
          5        BIND_LEXICAL                                             ~2, !0
   15     6        SEND_VAL                                                 ~2
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $3      
          9        SEND_ARRAY                                               $3
         10        CHECK_UNDEF_ARGS                                         
         11        DO_FCALL                                      0  $4      
         12      > RETURN                                                   $4
   17    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvjY1T%3A6%240

Function %00%7Bclosure%7D%2Fin%2FvjY1T%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjY1T
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $y, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   11     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvjY1T%3A11%242'
          4        BIND_LEXICAL                                             ~2, !0
   14     5        SEND_VAL                                                 ~2
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   15     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvjY1T%3A9%241

Function %00%7Bclosure%7D%2Fin%2FvjY1T%3A11%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjY1T
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $z, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   13     2        INIT_FCALL                                               'array_merge'
          3        CAST                                          7  ~2      !0
          4        SEND_VAL                                                 ~2
          5        CAST                                          7  ~3      !1
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
   14     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvjY1T%3A11%242

Function %00%7Bclosure%7D%2Fin%2FvjY1T%3A20%243:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 13
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/vjY1T
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $tuple, !1 = $available, !2 = $count, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   22     2        INIT_FCALL                                               'array_count_values'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5      > FE_RESET_R                                       $5      $4, ->17
          6    > > FE_FETCH_R                                       ~6      $5, !2, ->17
          7    >   ASSIGN                                                   !3, ~6
   24     8        ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !1, !3
          9      > JMPZ_EX                                          ~8      ~8, ->13
         10    >   FETCH_DIM_R                                      ~9      !1, !3
         11        IS_SMALLER                                       ~10     ~9, !2
         12        BOOL                                             ~8      ~10
         13    > > JMPZ                                                     ~8, ->16
   26    14    >   FE_FREE                                                  $5
         15      > RETURN                                                   <false>
   22    16    > > JMP                                                      ->6
         17    >   FE_FREE                                                  $5
   29    18      > RETURN                                                   <true>
   30    19*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvjY1T%3A20%243

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.73 ms | 1396 KiB | 29 Q