3v4l.org

run code in 300+ PHP versions simultaneously
<?php $precision = 100000; $offset = 0; $prizes = [ ['name' => '1', 'chance' => '0.1'], ['name' => '2', 'chance' => '0.2'], ['name' => '3', 'chance' => '0.3'], ['name' => '4', 'chance' => '0.1'], ]; $reduce = $offset; foreach ($prizes as $index => $prize) { $prizes[$index]['min'] = $reduce; $reduce += $prize['chance'] * $precision; $prizes[$index]['max'] = $reduce; } var_dump($prizes);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/g3sMM
function name:  (null)
number of ops:  22
compiled vars:  !0 = $precision, !1 = $offset, !2 = $prizes, !3 = $reduce, !4 = $prize, !5 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 100000
    4     1        ASSIGN                                                   !1, 0
    5     2        ASSIGN                                                   !2, <array>
   12     3        ASSIGN                                                   !3, !1
   13     4      > FE_RESET_R                                       $10     !2, ->17
          5    > > FE_FETCH_R                                       ~11     $10, !4, ->17
          6    >   ASSIGN                                                   !5, ~11
   14     7        FETCH_DIM_W                                      $13     !2, !5
          8        ASSIGN_DIM                                               $13, 'min'
          9        OP_DATA                                                  !3
   15    10        FETCH_DIM_R                                      ~15     !4, 'chance'
         11        MUL                                              ~16     !0, ~15
         12        ASSIGN_OP                                     1          !3, ~16
   16    13        FETCH_DIM_W                                      $18     !2, !5
         14        ASSIGN_DIM                                               $18, 'max'
         15        OP_DATA                                                  !3
   13    16      > JMP                                                      ->5
         17    >   FE_FREE                                                  $10
   19    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.36 ms | 1395 KiB | 15 Q