3v4l.org

run code in 300+ 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 )); //$array = array_merge_recursive($arr1,$arr2,$arr3); $key= "three"; $array = array_column($collection, $key); If(count($array) != 1){ $avg = array_sum($array)/count($array); }Else{ $avg = $array[0]; } Echo $avg;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QPsiS
function name:  (null)
number of ops:  21
compiled vars:  !0 = $collection, !1 = $key, !2 = $array, !3 = $avg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, 'three'
   11     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   13     7        COUNT                                            ~8      !2
          8        IS_NOT_EQUAL                                             ~8, 1
          9      > JMPZ                                                     ~9, ->17
   14    10    >   INIT_FCALL                                               'array_sum'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $10     
         13        COUNT                                            ~11     !2
         14        DIV                                              ~12     $10, ~11
         15        ASSIGN                                                   !3, ~12
   13    16      > JMP                                                      ->19
   16    17    >   FETCH_DIM_R                                      ~14     !2, 0
         18        ASSIGN                                                   !3, ~14
   19    19    >   ECHO                                                     !3
         20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.78 ms | 1002 KiB | 15 Q