3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 0 => [ 'one' => 10, 'two' => 20, 'three' => 50, 'four' => 80, 'five' => 100], 1 => [ 'three' => 20, 'five' => 20, 'six' => 100, 'seven' => 10], 2 => [ 'one' => 30, 'three' => 30, 'five' => 10, 'eight' => 10] ]; $combined = []; foreach($input as $array) { foreach($array as $key => $value) { $combined[$key][] = $value; } } $combined = array_filter($combined, function($v, $k) { return count($v) != 1; }, ARRAY_FILTER_USE_BOTH ); $averages = array_map(function($item) { return array_sum($item)/count($item); }, $combined); var_dump($averages);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/dn5ro
function name:  (null)
number of ops:  31
compiled vars:  !0 = $input, !1 = $combined, !2 = $array, !3 = $value, !4 = $key, !5 = $averages
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   10     2      > FE_RESET_R                                       $8      !0, ->13
          3    > > FE_FETCH_R                                               $8, !2, ->13
   11     4    > > FE_RESET_R                                       $9      !2, ->11
          5    > > FE_FETCH_R                                       ~10     $9, !3, ->11
          6    >   ASSIGN                                                   !4, ~10
   12     7        FETCH_DIM_W                                      $12     !1, !4
          8        ASSIGN_DIM                                               $12
          9        OP_DATA                                                  !3
   11    10      > JMP                                                      ->5
         11    >   FE_FREE                                                  $9
   10    12      > JMP                                                      ->3
         13    >   FE_FREE                                                  $8
   16    14        INIT_FCALL                                               'array_filter'
         15        SEND_VAR                                                 !1
         16        DECLARE_LAMBDA_FUNCTION                          ~14     [0]
   18    17        SEND_VAL                                                 ~14
         18        SEND_VAL                                                 1
   16    19        DO_ICALL                                         $15     
         20        ASSIGN                                                   !1, $15
   20    21        INIT_FCALL                                               'array_map'
         22        DECLARE_LAMBDA_FUNCTION                          ~17     [1]
   22    23        SEND_VAL                                                 ~17
         24        SEND_VAR                                                 !1
   20    25        DO_ICALL                                         $18     
         26        ASSIGN                                                   !5, $18
   24    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !5
         29        DO_ICALL                                                 
         30      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dn5ro
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $v, !1 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        COUNT                                            ~2      !0
          3        IS_NOT_EQUAL                                     ~3      ~2, 1
          4      > RETURN                                                   ~3
   18     5*     > 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/dn5ro
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_FCALL                                               'array_sum'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        COUNT                                            ~2      !0
          5        DIV                                              ~3      $1, ~2
          6      > RETURN                                                   ~3
   22     7*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.07 ms | 1010 KiB | 17 Q