3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ean = '0092837701144'; $code = substr($ean, 0, -1); $sequence_ean8 = array(3, 1); $sequence_ean13 = array(1, 3); $sums = 0; foreach(str_split($code) as $n => $digit) { if (strlen($code)==7){ $sums += $digit * $sequence_ean8[$n % 2]; } elseif (strlen($code)==12){ $sums += $digit * $sequence_ean13[$n % 2]; } else { echo "code length invalid"; } } $checksum = 10 - $sums % 10; if($checksum == 10){ $checksum = 0; } var_dump($code . $checksum === $ean);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 34
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 34
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 41
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 34
filename:       /in/HHhFO
function name:  (null)
number of ops:  47
compiled vars:  !0 = $ean, !1 = $code, !2 = $sequence_ean8, !3 = $sequence_ean13, !4 = $sums, !5 = $digit, !6 = $n, !7 = $checksum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '0092837701144'
    3     1        INIT_FCALL                                               'substr'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 -1
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !1, $9
    5     7        ASSIGN                                                   !2, <array>
    6     8        ASSIGN                                                   !3, <array>
    8     9        ASSIGN                                                   !4, 0
   10    10        INIT_FCALL                                               'str_split'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $14     
         13      > FE_RESET_R                                       $15     $14, ->34
         14    > > FE_FETCH_R                                       ~16     $15, !5, ->34
         15    >   ASSIGN                                                   !6, ~16
   11    16        STRLEN                                           ~18     !1
         17        IS_EQUAL                                                 ~18, 7
         18      > JMPZ                                                     ~19, ->24
   12    19    >   MOD                                              ~20     !6, 2
         20        FETCH_DIM_R                                      ~21     !2, ~20
         21        MUL                                              ~22     !5, ~21
         22        ASSIGN_OP                                     1          !4, ~22
         23      > JMP                                                      ->33
   13    24    >   STRLEN                                           ~24     !1
         25        IS_EQUAL                                                 ~24, 12
         26      > JMPZ                                                     ~25, ->32
   14    27    >   MOD                                              ~26     !6, 2
         28        FETCH_DIM_R                                      ~27     !3, ~26
         29        MUL                                              ~28     !5, ~27
         30        ASSIGN_OP                                     1          !4, ~28
         31      > JMP                                                      ->33
   16    32    >   ECHO                                                     'code+length+invalid'
   10    33    > > JMP                                                      ->14
         34    >   FE_FREE                                                  $15
   20    35        MOD                                              ~30     !4, 10
         36        SUB                                              ~31     10, ~30
         37        ASSIGN                                                   !7, ~31
   22    38        IS_EQUAL                                                 !7, 10
         39      > JMPZ                                                     ~33, ->41
   23    40    >   ASSIGN                                                   !7, 0
   26    41    >   INIT_FCALL                                               'var_dump'
         42        CONCAT                                           ~35     !1, !7
         43        IS_IDENTICAL                                     ~36     !0, ~35
         44        SEND_VAL                                                 ~36
         45        DO_ICALL                                                 
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.83 ms | 1400 KiB | 19 Q