3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateNumbers() { $numbers = []; while ( count($numbers) < 2 ) { $number = rand(1,2); if ( !in_array($number, $numbers) ) { $numbers[] = $number; } } sort($numbers); return $numbers; } $numbers = generateNumbers(); $new = generateNumbers(); $allNewNumbers = []; $allNewNumbers[] = implode(',',$new); $counter = 1; while ( !empty(array_diff($numbers, $new)) ) { while ( in_array(implode(',',$new),$allNewNumbers) ) { $new = generateNumbers(); } $allNewNumbers[] = implode(',',$new); $counter++; echo 'counter: '.$counter.PHP_EOL; if ( $counter > 1000 ) { echo 'break'.PHP_EOL; break; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 15
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 16
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 42
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 16
Branch analysis from position: 28
Branch analysis from position: 16
filename:       /in/gHJLv
function name:  (null)
number of ops:  50
compiled vars:  !0 = $numbers, !1 = $new, !2 = $allNewNumbers, !3 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'generatenumbers'
          1        DO_FCALL                                      0  $4      
          2        ASSIGN                                                   !0, $4
   14     3        INIT_FCALL                                               'generatenumbers'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   15     6        ASSIGN                                                   !2, <array>
   16     7        INIT_FCALL                                               'implode'
          8        SEND_VAL                                                 '%2C'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $10     
         11        ASSIGN_DIM                                               !2
         12        OP_DATA                                                  $10
   17    13        ASSIGN                                                   !3, 1
   18    14      > JMP                                                      ->42
   19    15    > > JMP                                                      ->19
   20    16    >   INIT_FCALL                                               'generatenumbers'
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !1, $12
   19    19    >   INIT_FCALL                                               'in_array'
         20        INIT_FCALL                                               'implode'
         21        SEND_VAL                                                 '%2C'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $14     
         24        SEND_VAR                                                 $14
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                         $15     
         27      > JMPNZ                                                    $15, ->16
   22    28    >   INIT_FCALL                                               'implode'
         29        SEND_VAL                                                 '%2C'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $17     
         32        ASSIGN_DIM                                               !2
         33        OP_DATA                                                  $17
   23    34        PRE_INC                                                  !3
   24    35        CONCAT                                           ~19     'counter%3A+', !3
         36        CONCAT                                           ~20     ~19, '%0A'
         37        ECHO                                                     ~20
   25    38        IS_SMALLER                                               1000, !3
         39      > JMPZ                                                     ~21, ->42
   26    40    >   ECHO                                                     'break%0A'
   27    41      > JMP                                                      ->49
   18    42    >   INIT_FCALL                                               'array_diff'
         43        SEND_VAR                                                 !0
         44        SEND_VAR                                                 !1
         45        DO_ICALL                                         $22     
         46        BOOL_NOT                                         ~23     $22
         47        BOOL_NOT                                         ~24     ~23
         48      > JMPNZ                                                    ~24, ->15
   29    49    > > RETURN                                                   1

Function generatenumbers:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 2
Branch analysis from position: 18
Branch analysis from position: 2
Branch analysis from position: 15
filename:       /in/gHJLv
function name:  generateNumbers
number of ops:  23
compiled vars:  !0 = $numbers, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1      > JMP                                                      ->15
    5     2    >   INIT_FCALL                                               'rand'
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 2
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
    6     7        INIT_FCALL                                               'in_array'
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $5      
         11        BOOL_NOT                                         ~6      $5
         12      > JMPZ                                                     ~6, ->15
    7    13    >   ASSIGN_DIM                                               !0
         14        OP_DATA                                                  !1
    4    15    >   COUNT                                            ~8      !0
         16        IS_SMALLER                                               ~8, 2
         17      > JMPNZ                                                    ~9, ->2
   10    18    >   INIT_FCALL                                               'sort'
         19        SEND_REF                                                 !0
         20        DO_ICALL                                                 
   11    21      > RETURN                                                   !0
   12    22*     > RETURN                                                   null

End of function generatenumbers

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.79 ms | 1022 KiB | 21 Q