3v4l.org

run code in 500+ PHP versions simultaneously
<?php $uniqueNumbers = 100; $picked = []; $randoms = array_map(function () use(&$picked, $uniqueNumbers) { do { $rand = rand(0, $uniqueNumbers); } while(in_array($rand, $picked)); $picked[] = $rand; return $rand; }, array_fill(0, $uniqueNumbers, null)); sort($randoms); var_dump($randoms);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mSWBo
function name:  (null)
number of ops:  22
compiled vars:  !0 = $uniqueNumbers, !1 = $picked, !2 = $randoms
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 100
    4     1        ASSIGN                                                       !1, <array>
    5     2        INIT_FCALL                                                   'array_map'
          3        DECLARE_LAMBDA_FUNCTION                              ~5      [0]
          4        BIND_LEXICAL                                                 ~5, !1
          5        BIND_LEXICAL                                                 ~5, !0
   13     6        SEND_VAL                                                     ~5
          7        INIT_FCALL                                                   'array_fill'
          8        SEND_VAL                                                     0
          9        SEND_VAR                                                     !0
         10        SEND_VAL                                                     null
         11        DO_ICALL                                             $6      
         12        SEND_VAR                                                     $6
    5    13        DO_ICALL                                             $7      
         14        ASSIGN                                                       !2, $7
   15    15        INIT_FCALL                                                   'sort'
         16        SEND_REF                                                     !2
         17        DO_ICALL                                                     
   17    18        INIT_FCALL                                                   'var_dump'
         19        SEND_VAR                                                     !2
         20        DO_ICALL                                                     
         21      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
filename:       /in/mSWBo
function name:  {closure:/in/mSWBo:5}
number of ops:  13
compiled vars:  !0 = $picked, !1 = $uniqueNumbers, !2 = $rand
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                                  !0
          1        BIND_STATIC                                                  !1
    7     2    >   INIT_FCALL                                                   'rand'
          3        SEND_VAL                                                     0
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $3      
          6        ASSIGN                                                       !2, $3
    8     7        FRAMELESS_ICALL_2                in_array            ~5      !2, !0
          8      > JMPNZ                                                        ~5, ->2
   10     9    >   ASSIGN_DIM                                                   !0
         10        OP_DATA                                                      !2
   12    11      > RETURN                                                       !2
   13    12*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.13 ms | 1160 KiB | 18 Q