3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Функция генерирует массив заполненный случайными числами * @param int limit - количество элементов массива * @param int min - минимальное значение элемента массива * @param int max - максимальное значение * @return array */ function array_fill_rand($limit, $min=false, $max=false) { $limit = (int)$limit; $array = array(); if ($min !== false && $max !== false) { $min = (int)$min; $max = (int)$max; for ($i=0; $i<$limit; $i++) { $array[$i] = rand($min, $max); } } else { for ($i=0; $i<$limit; $i++) { $array[$i] = rand(); } } return $array; } echo '<pre>'; // Массив из 5 элементов $rand_array = array_fill_rand(5); print_r($rand_array); // Массив из 10 элементов $rand_array = array_fill_rand(10); print_r($rand_array); // Массив из 5 элементов, со случайными числами в диапазоне от 0 до 10 $rand_array = array_fill_rand(5, 0, 10); print_r($rand_array); // Массив из 10 элементов, со случайными числами в диапазоне от -100 до 100 $rand_array = array_fill_rand(10, -100, 100); print_r($rand_array); echo '</pre>'; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/luApL
function name:  (null)
number of ops:  35
compiled vars:  !0 = $rand_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ECHO                                                     '%3Cpre%3E'
   38     1        INIT_FCALL                                               'array_fill_rand'
          2        SEND_VAL                                                 5
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   39     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   42     8        INIT_FCALL                                               'array_fill_rand'
          9        SEND_VAL                                                 10
         10        DO_FCALL                                      0  $4      
         11        ASSIGN                                                   !0, $4
   43    12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   46    15        INIT_FCALL                                               'array_fill_rand'
         16        SEND_VAL                                                 5
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 10
         19        DO_FCALL                                      0  $7      
         20        ASSIGN                                                   !0, $7
   47    21        INIT_FCALL                                               'print_r'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                                 
   50    24        INIT_FCALL                                               'array_fill_rand'
         25        SEND_VAL                                                 10
         26        SEND_VAL                                                 -100
         27        SEND_VAL                                                 100
         28        DO_FCALL                                      0  $10     
         29        ASSIGN                                                   !0, $10
   51    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                                 
   53    33        ECHO                                                     '%3C%2Fpre%3E'
   55    34      > RETURN                                                   1

Function array_fill_rand:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 27
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 17
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 17
Branch analysis from position: 26
Branch analysis from position: 17
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 29
Branch analysis from position: 36
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 29
Branch analysis from position: 36
Branch analysis from position: 29
Branch analysis from position: 10
filename:       /in/luApL
function name:  array_fill_rand
number of ops:  38
compiled vars:  !0 = $limit, !1 = $min, !2 = $max, !3 = $array, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
          2        RECV_INIT                                        !2      <false>
   12     3        CAST                                          4  ~5      !0
          4        ASSIGN                                                   !0, ~5
   13     5        ASSIGN                                                   !3, <array>
   15     6        TYPE_CHECK                                  1018  ~8      !1
          7      > JMPZ_EX                                          ~8      ~8, ->10
          8    >   TYPE_CHECK                                  1018  ~9      !2
          9        BOOL                                             ~8      ~9
         10    > > JMPZ                                                     ~8, ->27
   17    11    >   CAST                                          4  ~10     !1
         12        ASSIGN                                                   !1, ~10
   18    13        CAST                                          4  ~12     !2
         14        ASSIGN                                                   !2, ~12
   19    15        ASSIGN                                                   !4, 0
         16      > JMP                                                      ->24
   21    17    >   INIT_FCALL                                               'rand'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $16     
         21        ASSIGN_DIM                                               !3, !4
         22        OP_DATA                                                  $16
   19    23        PRE_INC                                                  !4
         24    >   IS_SMALLER                                               !4, !0
         25      > JMPNZ                                                    ~18, ->17
         26    > > JMP                                                      ->36
   26    27    >   ASSIGN                                                   !4, 0
         28      > JMP                                                      ->34
   28    29    >   INIT_FCALL                                               'rand'
         30        DO_ICALL                                         $21     
         31        ASSIGN_DIM                                               !3, !4
         32        OP_DATA                                                  $21
   26    33        PRE_INC                                                  !4
         34    >   IS_SMALLER                                               !4, !0
         35      > JMPNZ                                                    ~23, ->29
   32    36    > > RETURN                                                   !3
   33    37*     > RETURN                                                   null

End of function array_fill_rand

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.23 ms | 1403 KiB | 21 Q