3v4l.org

run code in 500+ PHP versions simultaneously
<?php $collection = array( Array ( 'one' => 10, 'two' => 20, 'three' => 50, 'four' => 80, 'five' => 100 ), Array ( 'three' => 20, 'five' => 20, 'six' => 100, 'seven' => 10 ), Array ( 'one' => 30, 'three' => 30, 'five' => 10, 'eight' => 10 )); Foreach($collection[0] as $key => $val){ $array = array_column($collection, $key); If(count($array) == count($collection)){ $avg[$key] = array_sum($array)/count($array); } } Var_dump($avg);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/LfktH
function name:  (null)
number of ops:  27
compiled vars:  !0 = $collection, !1 = $val, !2 = $key, !3 = $array, !4 = $avg
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    8     1        FETCH_DIM_R                                          ~6      !0, 0
          2      > FE_RESET_R                                           $7      ~6, ->22
          3    > > FE_FETCH_R                                           ~8      $7, !1, ->22
          4    >   ASSIGN                                                       !2, ~8
    9     5        INIT_FCALL                                                   'array_column'
          6        SEND_VAR                                                     !0
          7        SEND_VAR                                                     !2
          8        DO_ICALL                                             $10     
          9        ASSIGN                                                       !3, $10
   10    10        COUNT                                                ~12     !3
         11        COUNT                                                ~13     !0
         12        IS_EQUAL                                                     ~12, ~13
         13      > JMPZ                                                         ~14, ->21
   11    14    >   INIT_FCALL                                                   'array_sum'
         15        SEND_VAR                                                     !3
         16        DO_ICALL                                             $16     
         17        COUNT                                                ~17     !3
         18        DIV                                                  ~18     $16, ~17
         19        ASSIGN_DIM                                                   !4, !2
         20        OP_DATA                                                      ~18
    8    21    > > JMP                                                          ->3
         22    >   FE_FREE                                                      $7
   14    23        INIT_FCALL                                                   'var_dump'
         24        SEND_VAR                                                     !4
         25        DO_ICALL                                                     
         26      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
173.57 ms | 2245 KiB | 16 Q