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 ]; $difference = 0; foreach ($a as &$minuend) { while ($minuend && ($b || $difference < 0)) { $suprahend = $difference < 0 ? -$difference : array_shift($b); $difference = $minuend - $suprahend; $minuend = max(0, $difference); } } var_export($a);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 126) Position 1 = 5, Position 2 = 30
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
2 jumps found. (Code = 47) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 6
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
Branch analysis from position: 28
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
Branch analysis from position: 28
Branch analysis from position: 27
Branch analysis from position: 28
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/WkesI
function name:  (null)
number of ops:  35
compiled vars:  !0 = $a, !1 = $b, !2 = $difference, !3 = $minuend, !4 = $suprahend
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   16     2        ASSIGN                                                   !2, 0
   17     3      > FE_RESET_RW                                      $8      !0, ->30
          4    > > FE_FETCH_RW                                              $8, !3, ->30
   18     5    > > JMP                                                      ->23
   19     6    >   IS_SMALLER                                               !2, 0
          7      > JMPZ                                                     ~9, ->11
          8    >   MUL                                              ~10     !2, -1
          9        QM_ASSIGN                                        ~11     ~10
         10      > JMP                                                      ->15
         11    >   INIT_FCALL                                               'array_shift'
         12        SEND_REF                                                 !1
         13        DO_ICALL                                         $12     
         14        QM_ASSIGN                                        ~11     $12
         15    >   ASSIGN                                                   !4, ~11
   20    16        SUB                                              ~14     !3, !4
         17        ASSIGN                                                   !2, ~14
   21    18        INIT_FCALL                                               'max'
         19        SEND_VAL                                                 0
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $16     
         22        ASSIGN                                                   !3, $16
   18    23    > > JMPZ_EX                                          ~18     !3, ->28
         24    > > JMPNZ_EX                                         ~19     !1, ->27
         25    >   IS_SMALLER                                       ~20     !2, 0
         26        BOOL                                             ~19     ~20
         27    >   BOOL                                             ~18     ~19
         28    > > JMPNZ                                                    ~18, ->6
   17    29    > > JMP                                                      ->4
         30    >   FE_FREE                                                  $8
   24    31        INIT_FCALL                                               'var_export'
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.67 ms | 1007 KiB | 16 Q