3v4l.org

run code in 300+ PHP versions simultaneously
<?php $current = array( 750 => 2, 1000 => 1.3, 2000 => 1.2, 3000 => 1.1, 4000 => 1.0, 5000 => 0.9, 6000 => 0.8, 10000 => 0.75, ); function update($current) { $tiers = array( 0 => 3.5, 250 => 3.5, 500 => 3.5, 750 => 3, ); krsort($current); $prev = 0; foreach($current as $range => $spread) { if ( $range < 1000 ) continue; if ( $range >= 1000 && $range <= 5000 && $spread <= 1.1 ) $spread += 0.4; $prev = $tiers[$range] = max($spread, $prev); } ksort($tiers); return $tiers; } var_dump($current); var_dump(update($current));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v9W3a
function name:  (null)
number of ops:  11
compiled vars:  !0 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   37     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'update'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function update:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 21
Branch analysis from position: 19
Branch analysis from position: 16
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/v9W3a
function name:  update
number of ops:  35
compiled vars:  !0 = $current, !1 = $tiers, !2 = $prev, !3 = $spread, !4 = $range
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, <array>
   22     2        INIT_FCALL                                               'krsort'
          3        SEND_REF                                                 !0
          4        DO_ICALL                                                 
   23     5        ASSIGN                                                   !2, 0
   25     6      > FE_RESET_R                                       $8      !0, ->29
          7    > > FE_FETCH_R                                       ~9      $8, !3, ->29
          8    >   ASSIGN                                                   !4, ~9
   26     9        IS_SMALLER                                               !4, 1000
         10      > JMPZ                                                     ~11, ->12
   27    11    > > JMP                                                      ->7
   28    12    >   IS_SMALLER_OR_EQUAL                              ~12     1000, !4
         13      > JMPZ_EX                                          ~12     ~12, ->16
         14    >   IS_SMALLER_OR_EQUAL                              ~13     !4, 5000
         15        BOOL                                             ~12     ~13
         16    > > JMPZ_EX                                          ~12     ~12, ->19
         17    >   IS_SMALLER_OR_EQUAL                              ~14     !3, 1.1
         18        BOOL                                             ~12     ~14
         19    > > JMPZ                                                     ~12, ->21
   29    20    >   ASSIGN_OP                                     1          !3, 0.4
   30    21    >   INIT_FCALL                                               'max'
         22        SEND_VAR                                                 !3
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $17     
         25        ASSIGN_DIM                                       ~16     !1, !4
         26        OP_DATA                                                  $17
         27        ASSIGN                                                   !2, ~16
   25    28      > JMP                                                      ->7
         29    >   FE_FREE                                                  $8
   32    30        INIT_FCALL                                               'ksort'
         31        SEND_REF                                                 !1
         32        DO_ICALL                                                 
   33    33      > RETURN                                                   !1
   34    34*     > RETURN                                                   null

End of function update

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.84 ms | 1394 KiB | 22 Q