3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * take the range of characters and generate a string of all permutations * * @param array $range range of characters to itterate over * @param array $array input array - operated on by reference * @param int $depth how many chars to put in the resultant array should be * @param int $currentDepth internal variable to track how nested the current call is * @param string $prefix internal variable to know what to prefix the current string with * @return string permutations */ function foo($range, &$array, $depth = 1, $currentDepth = 0, $prefix = "") { $start = !$currentDepth; $currentDepth++; if ($currentDepth > $depth) { return; } foreach($range as $char) { if ($currentDepth === $depth) { $array[] = $prefix . $char; continue; } foo($range, $array, $depth, $currentDepth, $prefix . $char); } if ($start) { return implode($array, "\n"); } } $return = array(); echo foo(range('a', 'z'), $return, 2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DOVNs
function name:  (null)
number of ops:  12
compiled vars:  !0 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ASSIGN                                                   !0, <array>
   36     1        INIT_FCALL                                               'foo'
          2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 'a'
          4        SEND_VAL                                                 'z'
          5        DO_ICALL                                         $2      
          6        SEND_VAR                                                 $2
          7        SEND_REF                                                 !0
          8        SEND_VAL                                                 2
          9        DO_FCALL                                      0  $3      
         10        ECHO                                                     $3
         11      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 28
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 28
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/DOVNs
function name:  foo
number of ops:  36
compiled vars:  !0 = $range, !1 = $array, !2 = $depth, !3 = $currentDepth, !4 = $prefix, !5 = $start, !6 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      1
          3        RECV_INIT                                        !3      0
          4        RECV_INIT                                        !4      ''
   14     5        BOOL_NOT                                         ~7      !3
          6        ASSIGN                                                   !5, ~7
   15     7        PRE_INC                                                  !3
   17     8        IS_SMALLER                                               !2, !3
          9      > JMPZ                                                     ~10, ->11
   18    10    > > RETURN                                                   null
   21    11    > > FE_RESET_R                                       $11     !0, ->28
         12    > > FE_FETCH_R                                               $11, !6, ->28
   22    13    >   IS_IDENTICAL                                             !3, !2
         14      > JMPZ                                                     ~12, ->19
   23    15    >   CONCAT                                           ~14     !4, !6
         16        ASSIGN_DIM                                               !1
         17        OP_DATA                                                  ~14
   24    18      > JMP                                                      ->12
   27    19    >   INIT_FCALL_BY_NAME                                       'foo'
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !1
         22        SEND_VAR_EX                                              !2
         23        SEND_VAR_EX                                              !3
         24        CONCAT                                           ~15     !4, !6
         25        SEND_VAL_EX                                              ~15
         26        DO_FCALL                                      0          
   21    27      > JMP                                                      ->12
         28    >   FE_FREE                                                  $11
   30    29      > JMPZ                                                     !5, ->35
   31    30    >   INIT_FCALL                                               'implode'
         31        SEND_VAR                                                 !1
         32        SEND_VAL                                                 '%0A'
         33        DO_ICALL                                         $17     
         34      > RETURN                                                   $17
   33    35    > > RETURN                                                   null

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.03 ms | 1006 KiB | 16 Q