3v4l.org

run code in 500+ 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; } } $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/hmtj5
function name:  (null)
number of ops:  24
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_map'
         15        DECLARE_LAMBDA_FUNCTION                              ~14     [0]
   18    16        SEND_VAL                                                     ~14
         17        SEND_VAR                                                     !1
   16    18        DO_ICALL                                             $15     
         19        ASSIGN                                                       !5, $15
   20    20        INIT_FCALL                                                   'var_dump'
         21        SEND_VAR                                                     !5
         22        DO_ICALL                                                     
         23      > 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/hmtj5
function name:  {closure:/in/hmtj5:16}
number of ops:  8
compiled vars:  !0 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
   17     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
   18     7*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.21 ms | 2159 KiB | 16 Q