3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateRandomString($length = 22) { return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length); } $generated = []; for ($i = 0; $i < 1000000; $i++) { $generated[] = generateRandomString(); } var_dump(count(array_unique($generated)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/9d1qQ
function name:  (null)
number of ops:  18
compiled vars:  !0 = $generated, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->8
   10     3    >   INIT_FCALL                                               'generaterandomstring'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  $5
    9     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, 1000000
          9      > JMPNZ                                                    ~7, ->3
   13    10    >   INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'array_unique'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $8      
         14        COUNT                                            ~9      $8
         15        SEND_VAL                                                 ~9
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function generaterandomstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9d1qQ
function name:  generateRandomString
number of ops:  21
compiled vars:  !0 = $length, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      22
    5     1        INIT_FCALL                                               'substr'
          2        INIT_FCALL                                               'str_shuffle'
          3        INIT_FCALL                                               'str_repeat'
          4        ASSIGN                                           ~2      !1, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
          5        SEND_VAL                                                 ~2
          6        INIT_FCALL                                               'ceil'
          7        STRLEN                                           ~3      !1
          8        DIV                                              ~4      !0, ~3
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11        SEND_VAR                                                 $5
         12        DO_ICALL                                         $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                         $7      
         15        SEND_VAR                                                 $7
         16        SEND_VAL                                                 1
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $8      
         19      > RETURN                                                   $8
    6    20*     > RETURN                                                   null

End of function generaterandomstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.43 ms | 948 KiB | 27 Q