3v4l.org

run code in 300+ PHP versions simultaneously
<?php $weights = [1, 100, 111, 168, 569, 1652, 16549, 19999, 20000, 20001, 25649, 35216, 54961]; foreach($weights as $index => $weight) { $extra_weight = round($weight-20000, 3)/1000; $extra_cost = $extra_weight * 1.00; echo "Method 1: Weight= $weight , Extra Weight: $extra_weight \n"; echo "Method 1: Weight= $weight , Extra Cost: $extra_weight \n"; $extra_weight = round(($weight-20000)/1000, 0); $extra_cost = $extra_weight * 1.00; echo "Method 2: Weight= $weight , Extra Weight: $extra_weight \n"; echo "Method 2: Weight= $weight , Extra Cost: $extra_weight \n"; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 47
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 47
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/NtNUH
function name:  (null)
number of ops:  49
compiled vars:  !0 = $weights, !1 = $weight, !2 = $index, !3 = $extra_weight, !4 = $extra_cost
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1      > FE_RESET_R                                       $6      !0, ->47
          2    > > FE_FETCH_R                                       ~7      $6, !1, ->47
          3    >   ASSIGN                                                   !2, ~7
    7     4        INIT_FCALL                                               'round'
          5        SUB                                              ~9      !1, 20000
          6        SEND_VAL                                                 ~9
          7        SEND_VAL                                                 3
          8        DO_ICALL                                         $10     
          9        DIV                                              ~11     $10, 1000
         10        ASSIGN                                                   !3, ~11
    8    11        MUL                                              ~13     !3, 1
         12        ASSIGN                                                   !4, ~13
   10    13        ROPE_INIT                                     5  ~16     'Method+1%3A+Weight%3D+'
         14        ROPE_ADD                                      1  ~16     ~16, !1
         15        ROPE_ADD                                      2  ~16     ~16, '+%2C+Extra+Weight%3A+'
         16        ROPE_ADD                                      3  ~16     ~16, !3
         17        ROPE_END                                      4  ~15     ~16, '+%0A'
         18        ECHO                                                     ~15
   11    19        ROPE_INIT                                     5  ~20     'Method+1%3A+Weight%3D+'
         20        ROPE_ADD                                      1  ~20     ~20, !1
         21        ROPE_ADD                                      2  ~20     ~20, '+%2C+Extra+Cost%3A+'
         22        ROPE_ADD                                      3  ~20     ~20, !3
         23        ROPE_END                                      4  ~19     ~20, '+%0A'
         24        ECHO                                                     ~19
   14    25        INIT_FCALL                                               'round'
         26        SUB                                              ~23     !1, 20000
         27        DIV                                              ~24     ~23, 1000
         28        SEND_VAL                                                 ~24
         29        SEND_VAL                                                 0
         30        DO_ICALL                                         $25     
         31        ASSIGN                                                   !3, $25
   15    32        MUL                                              ~27     !3, 1
         33        ASSIGN                                                   !4, ~27
   17    34        ROPE_INIT                                     5  ~30     'Method+2%3A+Weight%3D+'
         35        ROPE_ADD                                      1  ~30     ~30, !1
         36        ROPE_ADD                                      2  ~30     ~30, '+%2C+Extra+Weight%3A+'
         37        ROPE_ADD                                      3  ~30     ~30, !3
         38        ROPE_END                                      4  ~29     ~30, '+%0A'
         39        ECHO                                                     ~29
   18    40        ROPE_INIT                                     5  ~34     'Method+2%3A+Weight%3D+'
         41        ROPE_ADD                                      1  ~34     ~34, !1
         42        ROPE_ADD                                      2  ~34     ~34, '+%2C+Extra+Cost%3A+'
         43        ROPE_ADD                                      3  ~34     ~34, !3
         44        ROPE_END                                      4  ~33     ~34, '+%0A'
         45        ECHO                                                     ~33
    6    46      > JMP                                                      ->2
         47    >   FE_FREE                                                  $6
   21    48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.18 ms | 1392 KiB | 15 Q