3v4l.org

run code in 300+ PHP versions simultaneously
<?php function shuffleX($arr, $max=3){ $raw=$arr; $x=0; $s=md5('random_string'); while(1){$x++; shuffle($arr); //Build string out of Arr for repeating variables to check $f2=join($s,$arr); $break=true; foreach($raw as $k=>$v){ //Check for repeating variables each Value (forward and Backward) $f=str_repeat($v.$s,$max); $fa=str_repeat($s.$v.'',$max); if(preg_match('#'.$f.'#',$f2) OR preg_match('#'.$fa.'#',$f2)){ $break=false; } } if($break===true){return $arr;} if($x>(count($arr)*1000)){// if nothing found after x Times break or give an empty array return array('unpossible'); } } } $arr=array(1,2,1,1,2,2,1,2,1,2,1); print_r(shuffleX($arr,3)); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bFjZ5
function name:  (null)
number of ops:  9
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, <array>
   30     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'shufflex'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 3
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   32     8      > RETURN                                                   1

Function shufflex:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 9
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 52
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 52
Branch analysis from position: 21
2 jumps found. (Code = 47) Position 1 = 42, Position 2 = 49
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 51
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 51
Branch analysis from position: 49
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 56
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
Branch analysis from position: 52
filename:       /in/bFjZ5
function name:  shuffleX
number of ops:  63
compiled vars:  !0 = $arr, !1 = $max, !2 = $raw, !3 = $x, !4 = $s, !5 = $f2, !6 = $break, !7 = $v, !8 = $k, !9 = $f, !10 = $fa
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      3
    3     2        ASSIGN                                                   !2, !0
    4     3        ASSIGN                                                   !3, 0
    5     4        INIT_FCALL                                               'md5'
          5        SEND_VAL                                                 'random_string'
          6        DO_ICALL                                         $13     
          7        ASSIGN                                                   !4, $13
    6     8      > JMP                                                      ->61
          9    >   PRE_INC                                                  !3
    7    10        INIT_FCALL                                               'shuffle'
         11        SEND_REF                                                 !0
         12        DO_ICALL                                                 
    9    13        INIT_FCALL                                               'join'
         14        SEND_VAR                                                 !4
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $17     
         17        ASSIGN                                                   !5, $17
   10    18        ASSIGN                                                   !6, <true>
   12    19      > FE_RESET_R                                       $20     !2, ->52
         20    > > FE_FETCH_R                                       ~21     $20, !7, ->52
         21    >   ASSIGN                                                   !8, ~21
   14    22        INIT_FCALL                                               'str_repeat'
         23        CONCAT                                           ~23     !7, !4
         24        SEND_VAL                                                 ~23
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $24     
         27        ASSIGN                                                   !9, $24
   15    28        INIT_FCALL                                               'str_repeat'
         29        CONCAT                                           ~26     !4, !7
         30        CONCAT                                           ~27     ~26, ''
         31        SEND_VAL                                                 ~27
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                         $28     
         34        ASSIGN                                                   !10, $28
   17    35        INIT_FCALL                                               'preg_match'
         36        CONCAT                                           ~30     '%23', !9
         37        CONCAT                                           ~31     ~30, '%23'
         38        SEND_VAL                                                 ~31
         39        SEND_VAR                                                 !5
         40        DO_ICALL                                         $32     
         41      > JMPNZ_EX                                         ~33     $32, ->49
         42    >   INIT_FCALL                                               'preg_match'
         43        CONCAT                                           ~34     '%23', !10
         44        CONCAT                                           ~35     ~34, '%23'
         45        SEND_VAL                                                 ~35
         46        SEND_VAR                                                 !5
         47        DO_ICALL                                         $36     
         48        BOOL                                             ~33     $36
         49    > > JMPZ                                                     ~33, ->51
   18    50    >   ASSIGN                                                   !6, <false>
   12    51    > > JMP                                                      ->20
         52    >   FE_FREE                                                  $20
   22    53        TYPE_CHECK                                    8          !6
         54      > JMPZ                                                     ~38, ->56
         55    > > RETURN                                                   !0
   23    56    >   COUNT                                            ~39     !0
         57        MUL                                              ~40     ~39, 1000
         58        IS_SMALLER                                               ~40, !3
         59      > JMPZ                                                     ~41, ->61
   24    60    > > RETURN                                                   <array>
    6    61    > > JMPNZ                                                    1, ->9
   28    62    > > RETURN                                                   null

End of function shufflex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
131.82 ms | 1023 KiB | 20 Q