3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multi = [ "A2" => [ 0 => "A1", 1 => "A2", 2 => "A3", ], "A1" => [ 0 => "A1", 1 => "A6", 2 => "A5", 3 => "A2", ], "A6" => [ 0 => "A3", ], "A3" => [ 0 => "A3", 1 => "A2", ], "A5" => [ 0 => "A4" ], "A4" => [ 0 => "A4", 1 => "A3", ] ]; $single = [ "A1" => 675.58333333333, "A2" => 1786.75, "A3" => 2897.9166666667, "A4" => 4009.0833333333, "A5" => 5120.25, "A6" => 6231.4166666667, ]; $result = []; foreach ($multi as $key => $row) { $values = array_intersect_key($single, array_flip($row)); $result[$key] = array_sum($values) / count($values); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/GgQ0T
function name:  (null)
number of ops:  27
compiled vars:  !0 = $multi, !1 = $single, !2 = $result, !3 = $row, !4 = $key, !5 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   31     1        ASSIGN                                                   !1, <array>
   40     2        ASSIGN                                                   !2, <array>
   41     3      > FE_RESET_R                                       $9      !0, ->22
          4    > > FE_FETCH_R                                       ~10     $9, !3, ->22
          5    >   ASSIGN                                                   !4, ~10
   42     6        INIT_FCALL                                               'array_intersect_key'
          7        SEND_VAR                                                 !1
          8        INIT_FCALL                                               'array_flip'
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $12     
         11        SEND_VAR                                                 $12
         12        DO_ICALL                                         $13     
         13        ASSIGN                                                   !5, $13
   43    14        INIT_FCALL                                               'array_sum'
         15        SEND_VAR                                                 !5
         16        DO_ICALL                                         $16     
         17        COUNT                                            ~17     !5
         18        DIV                                              ~18     $16, ~17
         19        ASSIGN_DIM                                               !2, !4
         20        OP_DATA                                                  ~18
   41    21      > JMP                                                      ->4
         22    >   FE_FREE                                                  $9
   45    23        INIT_FCALL                                               'var_export'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.9 ms | 1406 KiB | 21 Q