3v4l.org

run code in 300+ PHP versions simultaneously
<?php function insert_random_chars($str, $alphabet = "ABCDEFGHIJKLMNOPGRSTUVWXYZ") { // An array to hold the result $result = array(); // The highest character index in the string $max = strlen($alphabet) - 1; // Loop the characters in the input string foreach (str_split($str, 1) as $char) { // Add the current character and a random character to the output array array_push($result, $char, $alphabet[mt_rand(0, $max)]); } // Join the output array together return implode('', $result); } echo insert_random_chars("0123456789");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oKvZ0
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'insert_random_chars'
          1        SEND_VAL                                                 '0123456789'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function insert_random_chars:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/oKvZ0
function name:  insert_random_chars
number of ops:  30
compiled vars:  !0 = $str, !1 = $alphabet, !2 = $result, !3 = $max, !4 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'ABCDEFGHIJKLMNOPGRSTUVWXYZ'
    6     2        ASSIGN                                                   !2, <array>
    9     3        STRLEN                                           ~6      !1
          4        SUB                                              ~7      ~6, 1
          5        ASSIGN                                                   !3, ~7
   12     6        INIT_FCALL                                               'str_split'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $9      
         10      > FE_RESET_R                                       $10     $9, ->23
         11    > > FE_FETCH_R                                               $10, !4, ->23
   14    12    >   INIT_FCALL                                               'array_push'
         13        SEND_REF                                                 !2
         14        SEND_VAR                                                 !4
         15        INIT_FCALL                                               'mt_rand'
         16        SEND_VAL                                                 0
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $11     
         19        FETCH_DIM_R                                      ~12     !1, $11
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                                 
   12    22      > JMP                                                      ->11
         23    >   FE_FREE                                                  $10
   18    24        INIT_FCALL                                               'implode'
         25        SEND_VAL                                                 ''
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $14     
         28      > RETURN                                                   $14
   19    29*     > RETURN                                                   null

End of function insert_random_chars

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.6 ms | 1402 KiB | 23 Q