3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ [ 472 => [ 'EL' => 52.9, 'MT' => 57.375, 'MO' => 56.6, 'SC' => 26, 'ET' => 50.775 ] ], [ 505 => [ 'EL' => 53.425, 'MT' => 25, 'MO' => 62.8, 'SC' => 23, 'ET' => 25 ] ] ]; $total = array_reduce( $arr, function($arr, $key) { $id = key($key); $consumed = $key[$id]; $sc = array_keys($consumed); $arr[$id] = [ "totalc" => array_sum($consumed), "condition" => checkMin($consumed, 26, ["SC" => 23]) ]; return $arr; }, [] ); function checkMin($arr, $min, $exception) { foreach($arr as $k => $v) { if ($v < (isset($exception[$k]) ? $exception[$k] : $min)) return false; } return true; } print_r($total);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QXaj0
function name:  (null)
number of ops:  12
compiled vars:  !0 = $arr, !1 = $total
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   23     1        INIT_FCALL                                                   'array_reduce'
   24     2        SEND_VAR                                                     !0
   25     3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
   34     4        SEND_VAL                                                     ~3
   35     5        SEND_VAL                                                     <array>
   23     6        DO_ICALL                                             $4      
          7        ASSIGN                                                       !1, $4
   47     8        INIT_FCALL                                                   'print_r'
          9        SEND_VAR                                                     !1
         10        DO_ICALL                                                     
         11      > 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/QXaj0
function name:  {closure:/in/QXaj0:25}
number of ops:  26
compiled vars:  !0 = $arr, !1 = $key, !2 = $id, !3 = $consumed, !4 = $sc
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   26     2        INIT_FCALL                                                   'key'
          3        SEND_VAR                                                     !1
          4        DO_ICALL                                             $5      
          5        ASSIGN                                                       !2, $5
   27     6        FETCH_DIM_R                                          ~7      !1, !2
          7        ASSIGN                                                       !3, ~7
   28     8        INIT_FCALL                                                   'array_keys'
          9        SEND_VAR                                                     !3
         10        DO_ICALL                                             $9      
         11        ASSIGN                                                       !4, $9
   30    12        INIT_FCALL                                                   'array_sum'
         13        SEND_VAR                                                     !3
         14        DO_ICALL                                             $12     
         15        INIT_ARRAY                                           ~13     $12, 'totalc'
   31    16        INIT_FCALL_BY_NAME                                           'checkMin'
         17        SEND_VAR_EX                                                  !3
         18        SEND_VAL_EX                                                  26
         19        SEND_VAL_EX                                                  <array>
         20        DO_FCALL                                          0  $14     
         21        ADD_ARRAY_ELEMENT                                    ~13     $14, 'condition'
   29    22        ASSIGN_DIM                                                   !0, !2
   31    23        OP_DATA                                                      ~13
   33    24      > RETURN                                                       !0
   34    25*     > RETURN                                                       null

End of Dynamic Function 0

Function checkmin:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/QXaj0
function name:  checkMin
number of ops:  20
compiled vars:  !0 = $arr, !1 = $min, !2 = $exception, !3 = $v, !4 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   40     3      > FE_RESET_R                                           $5      !0, ->17
          4    > > FE_FETCH_R                                           ~6      $5, !3, ->17
          5    >   ASSIGN                                                       !4, ~6
   41     6        ISSET_ISEMPTY_DIM_OBJ                             0          !2, !4
          7      > JMPZ                                                         ~8, ->11
          8    >   FETCH_DIM_R                                          ~9      !2, !4
          9        QM_ASSIGN                                            ~10     ~9
         10      > JMP                                                          ->12
         11    >   QM_ASSIGN                                            ~10     !1
         12    >   IS_SMALLER                                                   !3, ~10
         13      > JMPZ                                                         ~11, ->16
   42    14    >   FE_FREE                                                      $5
         15      > RETURN                                                       <false>
   40    16    > > JMP                                                          ->4
         17    >   FE_FREE                                                      $5
   44    18      > RETURN                                                       <true>
   45    19*     > RETURN                                                       null

End of function checkmin

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.79 ms | 2058 KiB | 17 Q