3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getArray($fill,$noOfItem){ $maxIndex = floor($noOfItem/$fill); $rang = range(1,20); $finalArray = []; foreach($rang as $key => $val){ if($val % $maxIndex == 0 && array_sum($finalArray) < $fill){ $finalArray[] =1; }else{ $finalArray[] =0; } } if($finalArray[0] == 1 && $finalArray[count($finalArray)-1] == 0){ $finalArray[0] = 0; $finalArray[count($finalArray)-1] = 1; } print_r($finalArray); } getArray(6,20); getArray(8,20); getArray(19,20); Output: https://3v4l.org/QY6HQ
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gQeHa
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'getarray'
          1        SEND_VAL                                                 6
          2        SEND_VAL                                                 20
          3        DO_FCALL                                      0          
   28     4        INIT_FCALL                                               'getarray'
          5        SEND_VAL                                                 8
          6        SEND_VAL                                                 20
          7        DO_FCALL                                      0          
   29     8        INIT_FCALL                                               'getarray'
          9        SEND_VAL                                                 19
         10        SEND_VAL                                                 20
         11        DO_FCALL                                      0          
   30    12      > RETURN                                                   1

Function getarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 31
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 24
Branch analysis from position: 31
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 47
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 40
Branch analysis from position: 31
filename:       /in/gQeHa
function name:  getArray
number of ops:  51
compiled vars:  !0 = $fill, !1 = $noOfItem, !2 = $maxIndex, !3 = $rang, !4 = $finalArray, !5 = $val, !6 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'floor'
          3        DIV                                              ~7      !1, !0
          4        SEND_VAL                                                 ~7
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !2, $8
    8     7        INIT_FCALL                                               'range'
          8        SEND_VAL                                                 1
          9        SEND_VAL                                                 20
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !3, $10
   10    12        ASSIGN                                                   !4, <array>
   12    13      > FE_RESET_R                                       $13     !3, ->31
         14    > > FE_FETCH_R                                       ~14     $13, !5, ->31
         15    >   ASSIGN                                                   !6, ~14
   13    16        MOD                                              ~16     !5, !2
         17        IS_EQUAL                                         ~17     ~16, 0
         18      > JMPZ_EX                                          ~17     ~17, ->24
         19    >   INIT_FCALL                                               'array_sum'
         20        SEND_VAR                                                 !4
         21        DO_ICALL                                         $18     
         22        IS_SMALLER                                       ~19     $18, !0
         23        BOOL                                             ~17     ~19
         24    > > JMPZ                                                     ~17, ->28
   14    25    >   ASSIGN_DIM                                               !4
         26        OP_DATA                                                  1
   13    27      > JMP                                                      ->30
   16    28    >   ASSIGN_DIM                                               !4
         29        OP_DATA                                                  0
   12    30    > > JMP                                                      ->14
         31    >   FE_FREE                                                  $13
   19    32        FETCH_DIM_R                                      ~22     !4, 0
         33        IS_EQUAL                                         ~23     ~22, 1
         34      > JMPZ_EX                                          ~23     ~23, ->40
         35    >   COUNT                                            ~24     !4
         36        SUB                                              ~25     ~24, 1
         37        FETCH_DIM_R                                      ~26     !4, ~25
         38        IS_EQUAL                                         ~27     ~26, 0
         39        BOOL                                             ~23     ~27
         40    > > JMPZ                                                     ~23, ->47
   20    41    >   ASSIGN_DIM                                               !4, 0
         42        OP_DATA                                                  0
   21    43        COUNT                                            ~29     !4
         44        SUB                                              ~30     ~29, 1
         45        ASSIGN_DIM                                               !4, ~30
         46        OP_DATA                                                  1
   24    47    >   INIT_FCALL                                               'print_r'
         48        SEND_VAR                                                 !4
         49        DO_ICALL                                                 
   25    50      > RETURN                                                   null

End of function getarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.86 ms | 1021 KiB | 20 Q