3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [101 => 5, 109 => 100, 220 => 50, 231 => 45, 245 => 90]; $b = ['PRO' => 12, 'LOG' => 15, 'DEV' => 100]; $rest = 0; foreach ($a as &$value) { if ($value < $rest) { $rest -= $value; $value = 0; continue; } else { $value -= $rest; $rest = 0; } while ($value > 0 && key($b) !== null) { if ($value < current($b)) { $rest = current($b) - $value; $value = 0; } else { $value = $value - current($b); $rest = 0; } next($b); } } var_dump($a);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 4, Position 2 = 44
Branch analysis from position: 4
2 jumps found. (Code = 126) Position 1 = 5, Position 2 = 44
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 14
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
Branch analysis from position: 42
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
Branch analysis from position: 42
Branch analysis from position: 42
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/g49o0
function name:  (null)
number of ops:  49
compiled vars:  !0 = $a, !1 = $b, !2 = $rest, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, 0
    7     3      > FE_RESET_RW                                      $7      !0, ->44
          4    > > FE_FETCH_RW                                              $7, !3, ->44
    8     5    >   IS_SMALLER                                               !3, !2
          6      > JMPZ                                                     ~8, ->11
    9     7    >   ASSIGN_OP                                     2          !2, !3
   10     8        ASSIGN                                                   !3, 0
   11     9      > JMP                                                      ->4
    8    10*       JMP                                                      ->13
   13    11    >   ASSIGN_OP                                     2          !3, !2
   14    12        ASSIGN                                                   !2, 0
   17    13      > JMP                                                      ->35
   18    14    >   INIT_FCALL                                               'current'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $13     
         17        IS_SMALLER                                               !3, $13
         18      > JMPZ                                                     ~14, ->26
   19    19    >   INIT_FCALL                                               'current'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $15     
         22        SUB                                              ~16     $15, !3
         23        ASSIGN                                                   !2, ~16
   20    24        ASSIGN                                                   !3, 0
   18    25      > JMP                                                      ->32
   22    26    >   INIT_FCALL                                               'current'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $19     
         29        SUB                                              ~20     !3, $19
         30        ASSIGN                                                   !3, ~20
   23    31        ASSIGN                                                   !2, 0
   26    32    >   INIT_FCALL                                               'next'
         33        SEND_REF                                                 !1
         34        DO_ICALL                                                 
   17    35    >   IS_SMALLER                                       ~24     0, !3
         36      > JMPZ_EX                                          ~24     ~24, ->42
         37    >   INIT_FCALL                                               'key'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                         $25     
         40        TYPE_CHECK                                  1020  ~26     $25
         41        BOOL                                             ~24     ~26
         42    > > JMPNZ                                                    ~24, ->14
    7    43    > > JMP                                                      ->4
         44    >   FE_FREE                                                  $7
   30    45        INIT_FCALL                                               'var_dump'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                                 
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
128.26 ms | 1008 KiB | 17 Q