3v4l.org

run code in 300+ PHP versions simultaneously
<?php $format = 'AAA-###000'; $voucherCode = ''; $charSet = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; //removed O and I, they can easily be mistaken for numbers $numberSet = '0123456789'; $length = strlen($format); $charCount = strlen($charSet); $numberCount = strlen($numberSet); for ($i=0; $i < $length; $i++) { if ($format[$i] == '#') //alpha $voucherCode .= substr($charSet, mt_rand(0, $charCount-1), 1); elseif($format[$i] == '0') //numerical $voucherCode .= substr($numberSet, mt_rand(0, $numberCount-1), 1); else //specific alpha character $voucherCode .= $format[$i]; } echo $voucherCode;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 12
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 27
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 12
Branch analysis from position: 47
Branch analysis from position: 12
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 42
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 47, Position 2 = 12
Branch analysis from position: 47
Branch analysis from position: 12
filename:       /in/jgEqv
function name:  (null)
number of ops:  49
compiled vars:  !0 = $format, !1 = $voucherCode, !2 = $charSet, !3 = $numberSet, !4 = $length, !5 = $charCount, !6 = $numberCount, !7 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'AAA-%23%23%23000'
    5     1        ASSIGN                                                   !1, ''
    6     2        ASSIGN                                                   !2, 'ABCDEFGHJKLMNPQRSTUVWXYZ'
    7     3        ASSIGN                                                   !3, '0123456789'
    9     4        STRLEN                                           ~12     !0
          5        ASSIGN                                                   !4, ~12
   10     6        STRLEN                                           ~14     !2
          7        ASSIGN                                                   !5, ~14
   11     8        STRLEN                                           ~16     !3
          9        ASSIGN                                                   !6, ~16
   13    10        ASSIGN                                                   !7, 0
         11      > JMP                                                      ->45
   14    12    >   FETCH_DIM_R                                      ~19     !0, !7
         13        IS_EQUAL                                                 ~19, '%23'
         14      > JMPZ                                                     ~20, ->27
   15    15    >   INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !2
         17        INIT_FCALL                                               'mt_rand'
         18        SEND_VAL                                                 0
         19        SUB                                              ~21     !5, 1
         20        SEND_VAL                                                 ~21
         21        DO_ICALL                                         $22     
         22        SEND_VAR                                                 $22
         23        SEND_VAL                                                 1
         24        DO_ICALL                                         $23     
         25        ASSIGN_OP                                     8          !1, $23
         26      > JMP                                                      ->44
   16    27    >   FETCH_DIM_R                                      ~25     !0, !7
         28        IS_EQUAL                                                 ~25, '0'
         29      > JMPZ                                                     ~26, ->42
   17    30    >   INIT_FCALL                                               'substr'
         31        SEND_VAR                                                 !3
         32        INIT_FCALL                                               'mt_rand'
         33        SEND_VAL                                                 0
         34        SUB                                              ~27     !6, 1
         35        SEND_VAL                                                 ~27
         36        DO_ICALL                                         $28     
         37        SEND_VAR                                                 $28
         38        SEND_VAL                                                 1
         39        DO_ICALL                                         $29     
         40        ASSIGN_OP                                     8          !1, $29
         41      > JMP                                                      ->44
   19    42    >   FETCH_DIM_R                                      ~31     !0, !7
         43        ASSIGN_OP                                     8          !1, ~31
   13    44    >   PRE_INC                                                  !7
         45    >   IS_SMALLER                                               !7, !4
         46      > JMPNZ                                                    ~34, ->12
   22    47    >   ECHO                                                     !1
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.18 ms | 1400 KiB | 17 Q