3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculate_hub_sortation_check_digit($str_hub_sortation_prefix) { $arr_split_prefix = str_split($str_hub_sortation_prefix); $int_weight = 19; $int_total = 0; // calculate position coefficient foreach($arr_split_prefix as $int_i => $mix_value) { $int_total += $mix_value * $int_weight; $int_weight--; } // modulus 11 $int_hub_check_digit = $int_total % 11; // if modulus is 10, check digit is repetition of last digit if ($int_hub_check_digit === 10) { $int_hub_check_digit = array_pop($arr_split_prefix); } return $int_hub_check_digit; } echo calculate_hub_sortation_check_digit('0465011111500021021');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mhAUE
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'calculate_hub_sortation_check_digit'
          1        SEND_VAL                                                 '0465011111500021021'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function calculate_hub_sortation_check_digit:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 14
filename:       /in/mhAUE
function name:  calculate_hub_sortation_check_digit
number of ops:  25
compiled vars:  !0 = $str_hub_sortation_prefix, !1 = $arr_split_prefix, !2 = $int_weight, !3 = $int_total, !4 = $mix_value, !5 = $int_i, !6 = $int_hub_check_digit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'str_split'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
    5     5        ASSIGN                                                   !2, 19
    6     6        ASSIGN                                                   !3, 0
    8     7      > FE_RESET_R                                       $11     !1, ->14
          8    > > FE_FETCH_R                                       ~12     $11, !4, ->14
          9    >   ASSIGN                                                   !5, ~12
    9    10        MUL                                              ~14     !4, !2
         11        ASSIGN_OP                                     1          !3, ~14
   10    12        PRE_DEC                                                  !2
    8    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $11
   13    15        MOD                                              ~17     !3, 11
         16        ASSIGN                                                   !6, ~17
   15    17        IS_IDENTICAL                                             !6, 10
         18      > JMPZ                                                     ~19, ->23
   16    19    >   INIT_FCALL                                               'array_pop'
         20        SEND_REF                                                 !1
         21        DO_ICALL                                         $20     
         22        ASSIGN                                                   !6, $20
   18    23    > > RETURN                                                   !6
   19    24*     > RETURN                                                   null

End of function calculate_hub_sortation_check_digit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.57 ms | 1399 KiB | 18 Q