3v4l.org

run code in 300+ PHP versions simultaneously
<?php const THRESHOLD_PRICES = [ 2 => 8.23, 5 => 10.97, 10 => 13.28, 15 => 15.40, 20 => 18.15, 25 => 20.36, 30 => 22.84, 40 => 25.60, 50 => 28.35, 60 => 31.89, 70 => 36.23, 80 => 39.40, 90 => 42.52, 100 => 44.75 ]; function getThresholdPrice(int $search): float { if (isset(THRESHOLD_PRICES[$search])) { return THRESHOLD_PRICES[$search]; } foreach (THRESHOLD_PRICES as $threshold => $price) { if ($threshold > $search) { break; } } return $price; } foreach (range(1, 105, 13) as $test) { printf("%d => %.02f\n", $test, getThresholdPrice($test)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/VAZvY
function name:  (null)
number of ops:  19
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'THRESHOLD_PRICES', <array>
   32     1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 105
          4        SEND_VAL                                                 13
          5        DO_ICALL                                         $1      
          6      > FE_RESET_R                                       $2      $1, ->17
          7    > > FE_FETCH_R                                               $2, !0, ->17
   33     8    >   INIT_FCALL                                               'printf'
          9        SEND_VAL                                                 '%25d+%3D%3E+%25.02f%0A'
         10        SEND_VAR                                                 !0
         11        INIT_FCALL                                               'getthresholdprice'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $3      
         14        SEND_VAR                                                 $3
         15        DO_ICALL                                                 
   32    16      > JMP                                                      ->7
         17    >   FE_FREE                                                  $2
   34    18      > RETURN                                                   1

Function getthresholdprice:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 16
Branch analysis from position: 16
filename:       /in/VAZvY
function name:  getThresholdPrice
number of ops:  21
compiled vars:  !0 = $search, !1 = $price, !2 = $threshold
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        FETCH_CONSTANT                                   ~3      'THRESHOLD_PRICES'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~3, !0
          3      > JMPZ                                                     ~4, ->8
   22     4    >   FETCH_CONSTANT                                   ~5      'THRESHOLD_PRICES'
          5        FETCH_DIM_R                                      ~6      ~5, !0
          6        VERIFY_RETURN_TYPE                                       ~6
          7      > RETURN                                                   ~6
   24     8    >   FETCH_CONSTANT                                   ~7      'THRESHOLD_PRICES'
          9      > FE_RESET_R                                       $8      ~7, ->16
         10    > > FE_FETCH_R                                       ~9      $8, !1, ->16
         11    >   ASSIGN                                                   !2, ~9
   25    12        IS_SMALLER                                               !0, !2
         13      > JMPZ                                                     ~11, ->15
   26    14    > > JMP                                                      ->16
   24    15    > > JMP                                                      ->10
         16    >   FE_FREE                                                  $8
   29    17        VERIFY_RETURN_TYPE                                       !1
         18      > RETURN                                                   !1
   30    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function getthresholdprice

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.62 ms | 1008 KiB | 16 Q