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;}print "<pre>";$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/ogPoO
function name:  (null)
number of ops:  28
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ECHO                                                     '%3Cpre%3E'
          1        INIT_FCALL                                               'fillrandom'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 4
          4        DO_FCALL                                      0  $1      
          5        ASSIGN                                                   !0, $1
          6        INIT_FCALL                                               'ksort'
          7        SEND_REF                                                 !0
          8        DO_ICALL                                                 
          9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12        INIT_FCALL                                               'fillrandom'
         13        SEND_VAL                                                 <array>
         14        SEND_VAL                                                 2
         15        SEND_VAL                                                 2
         16        SEND_VAR                                                 !0
         17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FogPoO%3A3%241'
         18        SEND_VAL                                                 ~5
         19        DO_FCALL                                      0  $6      
         20        ASSIGN                                                   !0, $6
         21        INIT_FCALL                                               'ksort'
         22        SEND_REF                                                 !0
         23        DO_ICALL                                                 
         24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                                 
         27      > 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/ogPoO
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
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1
          2        RECV_INIT                                        !2      <true>
          3        RECV_INIT                                        !3      <array>
          4        RECV_INIT                                        !4      null
          5        ISSET_ISEMPTY_CV                                         !3
          6      > JMPZ                                                     ~7, ->16
          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
         16    >   TYPE_CHECK                                    2          !4
         17      > JMPZ                                                     ~13, ->21
         18    >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FogPoO%3A3%240'
         19        BIND_LEXICAL                                             ~14, !2
         20        ASSIGN                                                   !4, ~14
         21    >   ASSIGN                                                   !5, 0
         22      > JMP                                                      ->43
         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
         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
         42        PRE_INC                                                  !5
         43    >   IS_SMALLER                                               !5, !1
         44      > JMPNZ                                                    ~27, ->23
         45    > > RETURN                                                   !3
         46*     > RETURN                                                   null

End of function fillrandom

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

End of function %00%7Bclosure%7D%2Fin%2FogPoO%3A3%240

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

End of function %00%7Bclosure%7D%2Fin%2FogPoO%3A3%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.83 ms | 1406 KiB | 23 Q