3v4l.org

run code in 300+ PHP versions simultaneously
<?php $rfcs = ['Typed Properties', 'PHP Attributes', 'Functional Interfaces', 'Closure from callable function', 'Forbid dynamic calls to scope introspection functions', 'Callable prototypes']; $numberOfCharsBeforeTrimRequired = 150; $perRFC = (int)($numberOfCharsBeforeTrimRequired / count($rfcs)); $done = []; do { $lastTrimNeeded = count($rfcs); $remaining = 0; foreach ($rfcs as $i => $rfc) { if (strlen($rfc) <= $perRFC) { $done[] = $rfc; $remaining += $perRFC - strlen($rfc); unset($rfcs[$i]); } } $perRFC += (int)($remaining / count($rfcs)); } while ($lastTrimNeeded > count($rfcs)); foreach ($rfcs as $rfc) { $done[] = substr($rfc, 0, $perRFC); } // get total length to check algo $totalLen = 0; foreach ($done as $rfc) { $totalLen += strlen($rfc); } var_dump($done, $totalLen);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 22
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 7
Branch analysis from position: 31
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 41
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 41
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 48
Branch analysis from position: 44
2 jumps found. (Code = 78) Position 1 = 45, Position 2 = 48
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 41
Branch analysis from position: 7
Branch analysis from position: 23
filename:       /in/0bmDb
function name:  (null)
number of ops:  54
compiled vars:  !0 = $rfcs, !1 = $numberOfCharsBeforeTrimRequired, !2 = $perRFC, !3 = $done, !4 = $lastTrimNeeded, !5 = $remaining, !6 = $rfc, !7 = $i, !8 = $totalLen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 150
    6     2        COUNT                                            ~11     !0
          3        DIV                                              ~12     !1, ~11
          4        CAST                                          4  ~13     ~12
          5        ASSIGN                                                   !2, ~13
    7     6        ASSIGN                                                   !3, <array>
   10     7    >   COUNT                                            ~16     !0
          8        ASSIGN                                                   !4, ~16
   11     9        ASSIGN                                                   !5, 0
   13    10      > FE_RESET_R                                       $19     !0, ->23
         11    > > FE_FETCH_R                                       ~20     $19, !6, ->23
         12    >   ASSIGN                                                   !7, ~20
   14    13        STRLEN                                           ~22     !6
         14        IS_SMALLER_OR_EQUAL                                      ~22, !2
         15      > JMPZ                                                     ~23, ->22
   15    16    >   ASSIGN_DIM                                               !3
         17        OP_DATA                                                  !6
   16    18        STRLEN                                           ~25     !6
         19        SUB                                              ~26     !2, ~25
         20        ASSIGN_OP                                     1          !5, ~26
   17    21        UNSET_DIM                                                !0, !7
   13    22    > > JMP                                                      ->11
         23    >   FE_FREE                                                  $19
   21    24        COUNT                                            ~28     !0
         25        DIV                                              ~29     !5, ~28
         26        CAST                                          4  ~30     ~29
         27        ASSIGN_OP                                     1          !2, ~30
   22    28        COUNT                                            ~32     !0
         29        IS_SMALLER                                               ~32, !4
         30      > JMPNZ                                                    ~33, ->7
   24    31    > > FE_RESET_R                                       $34     !0, ->41
         32    > > FE_FETCH_R                                               $34, !6, ->41
   25    33    >   INIT_FCALL                                               'substr'
         34        SEND_VAR                                                 !6
         35        SEND_VAL                                                 0
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                         $36     
         38        ASSIGN_DIM                                               !3
         39        OP_DATA                                                  $36
   24    40      > JMP                                                      ->32
         41    >   FE_FREE                                                  $34
   29    42        ASSIGN                                                   !8, 0
   30    43      > FE_RESET_R                                       $38     !3, ->48
         44    > > FE_FETCH_R                                               $38, !6, ->48
   31    45    >   STRLEN                                           ~39     !6
         46        ASSIGN_OP                                     1          !8, ~39
   30    47      > JMP                                                      ->44
         48    >   FE_FREE                                                  $38
   34    49        INIT_FCALL                                               'var_dump'
         50        SEND_VAR                                                 !3
         51        SEND_VAR                                                 !8
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
285.47 ms | 1016 KiB | 15 Q