3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fillRandom($range, $num = 1, $value = TRUE, $data = array(), $anon = NULL) { if (empty($data)) $data = array_fill($range[0], $range[1]+1, FALSE); if ($anon === NULL) { $anon = function($el) use($value) { return $el !== $value; }; } for ($i=0; $i<$num; $i++) { do { $key = mt_rand($range[0], $range[1]); } while (isSet($data[$key]) && !$anon($data[$key])); $data[$key] = $value; } return $data;}$input = fillRandom(array(0, 5), 4);ksort($input);print_r($input);$input = fillRandom(array(0, 5), 2, 2, $input, function($el){ return $el === TRUE;});ksort($input);print_r($input);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BYX8q
function name:  (null)
number of ops:  27
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'fillrandom'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 4
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
          5        INIT_FCALL                                               'ksort'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
          8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
         11        INIT_FCALL                                               'fillrandom'
         12        SEND_VAL                                                 <array>
         13        SEND_VAL                                                 2
         14        SEND_VAL                                                 2
         15        SEND_VAR                                                 !0
         16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBYX8q%3A14%241'
         17        SEND_VAL                                                 ~5
         18        DO_FCALL                                      0  $6      
         19        ASSIGN                                                   !0, $6
         20        INIT_FCALL                                               'ksort'
         21        SEND_REF                                                 !0
         22        DO_ICALL                                                 
         23        INIT_FCALL                                               'print_r'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Function fillrandom:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 23
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 32, Position 2 = 39
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 23
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 23
Branch analysis from position: 45
Branch analysis from position: 23
Branch analysis from position: 23
Branch analysis from position: 39
Branch analysis from position: 21
Branch analysis from position: 16
filename:       /in/BYX8q
function name:  fillRandom
number of ops:  47
compiled vars:  !0 = $range, !1 = $num, !2 = $value, !3 = $data, !4 = $anon, !5 = $i, !6 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1
          2        RECV_INIT                                        !2      <true>
          3        RECV_INIT                                        !3      <array>
          4        RECV_INIT                                        !4      null
    4     5        ISSET_ISEMPTY_CV                                         !3
          6      > JMPZ                                                     ~7, ->16
    5     7    >   INIT_FCALL                                               'array_fill'
          8        FETCH_DIM_R                                      ~8      !0, 0
          9        SEND_VAL                                                 ~8
         10        FETCH_DIM_R                                      ~9      !0, 1
         11        ADD                                              ~10     ~9, 1
         12        SEND_VAL                                                 ~10
         13        SEND_VAL                                                 <false>
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !3, $11
    6    16    >   TYPE_CHECK                                    2          !4
         17      > JMPZ                                                     ~13, ->21
    7    18    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBYX8q%3A7%240'
         19        BIND_LEXICAL                                             ~14, !2
         20        ASSIGN                                                   !4, ~14
   11    21    >   ASSIGN                                                   !5, 0
         22      > JMP                                                      ->43
   13    23    >   INIT_FCALL                                               'mt_rand'
         24        FETCH_DIM_R                                      ~17     !0, 0
         25        SEND_VAL                                                 ~17
         26        FETCH_DIM_R                                      ~18     !0, 1
         27        SEND_VAL                                                 ~18
         28        DO_ICALL                                         $19     
         29        ASSIGN                                                   !6, $19
   14    30        ISSET_ISEMPTY_DIM_OBJ                         0  ~21     !3, !6
         31      > JMPZ_EX                                          ~21     ~21, ->39
         32    >   INIT_DYNAMIC_CALL                                        !4
         33        CHECK_FUNC_ARG                                           
         34        FETCH_DIM_FUNC_ARG                               $22     !3, !6
         35        SEND_FUNC_ARG                                            $22
         36        DO_FCALL                                      0  $23     
         37        BOOL_NOT                                         ~24     $23
         38        BOOL                                             ~21     ~24
         39    > > JMPNZ                                                    ~21, ->23
         40    >   ASSIGN_DIM                                               !3, !6
         41        OP_DATA                                                  !2
   11    42        PRE_INC                                                  !5
         43    >   IS_SMALLER                                               !5, !1
         44      > JMPNZ                                                    ~27, ->23
   14    45    > > RETURN                                                   !3
         46*     > RETURN                                                   null

End of function fillrandom

Function %00%7Bclosure%7D%2Fin%2FBYX8q%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BYX8q
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $el, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    8     2        IS_NOT_IDENTICAL                                 ~2      !0, !1
          3      > RETURN                                                   ~2
    9     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBYX8q%3A7%240

Function %00%7Bclosure%7D%2Fin%2FBYX8q%3A14%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BYX8q
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $el
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        TYPE_CHECK                                    8  ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBYX8q%3A14%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.26 ms | 1407 KiB | 23 Q