3v4l.org

run code in 300+ PHP versions simultaneously
<?php function distribute($players) { $ceil = ceil(count($players) / 2); $floor = floor(count($players) / 2); $ceilArray = array_chunk($players, $ceil); $floorArray = array_chunk($players, $floor); printf('%2d players. ceil %2d - %s'.PHP_EOL, count($players), $ceil, counts($ceilArray)); printf('%2d players. floor %2d - %s'.PHP_EOL, count($players), $floor, counts($floorArray)); } function counts($array) { $out = ''; foreach ($array as $dimension => $elements) { $out .= sprintf('team%d: %d; ', $dimension, count($elements)); } return $out; } distribute(range(1, 9)); distribute(range(1, 10)); distribute(range(1, 11));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DlmBq
function name:  (null)
number of ops:  22
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'distribute'
          1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 9
          4        DO_ICALL                                         $0      
          5        SEND_VAR                                                 $0
          6        DO_FCALL                                      0          
   21     7        INIT_FCALL                                               'distribute'
          8        INIT_FCALL                                               'range'
          9        SEND_VAL                                                 1
         10        SEND_VAL                                                 10
         11        DO_ICALL                                         $2      
         12        SEND_VAR                                                 $2
         13        DO_FCALL                                      0          
   22    14        INIT_FCALL                                               'distribute'
         15        INIT_FCALL                                               'range'
         16        SEND_VAL                                                 1
         17        SEND_VAL                                                 11
         18        DO_ICALL                                         $4      
         19        SEND_VAR                                                 $4
         20        DO_FCALL                                      0          
         21      > RETURN                                                   1

Function distribute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DlmBq
function name:  distribute
number of ops:  44
compiled vars:  !0 = $players, !1 = $ceil, !2 = $floor, !3 = $ceilArray, !4 = $floorArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'ceil'
          2        COUNT                                            ~5      !0
          3        DIV                                              ~6      ~5, 2
          4        SEND_VAL                                                 ~6
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !1, $7
    5     7        INIT_FCALL                                               'floor'
          8        COUNT                                            ~9      !0
          9        DIV                                              ~10     ~9, 2
         10        SEND_VAL                                                 ~10
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !2, $11
    6    13        INIT_FCALL                                               'array_chunk'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $13     
         17        ASSIGN                                                   !3, $13
    7    18        INIT_FCALL                                               'array_chunk'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $15     
         22        ASSIGN                                                   !4, $15
    8    23        INIT_FCALL                                               'printf'
         24        SEND_VAL                                                 '%252d+players.+ceil+%252d++-+%25s%0A'
         25        COUNT                                            ~17     !0
         26        SEND_VAL                                                 ~17
         27        SEND_VAR                                                 !1
         28        INIT_FCALL_BY_NAME                                       'counts'
         29        SEND_VAR_EX                                              !3
         30        DO_FCALL                                      0  $18     
         31        SEND_VAR                                                 $18
         32        DO_ICALL                                                 
    9    33        INIT_FCALL                                               'printf'
         34        SEND_VAL                                                 '%252d+players.+floor+%252d+-+%25s%0A'
         35        COUNT                                            ~20     !0
         36        SEND_VAL                                                 ~20
         37        SEND_VAR                                                 !2
         38        INIT_FCALL_BY_NAME                                       'counts'
         39        SEND_VAR_EX                                              !4
         40        DO_FCALL                                      0  $21     
         41        SEND_VAR                                                 $21
         42        DO_ICALL                                                 
   10    43      > RETURN                                                   null

End of function distribute

Function counts:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/DlmBq
function name:  counts
number of ops:  16
compiled vars:  !0 = $array, !1 = $out, !2 = $elements, !3 = $dimension
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ASSIGN                                                   !1, ''
   14     2      > FE_RESET_R                                       $5      !0, ->13
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->13
          4    >   ASSIGN                                                   !3, ~6
   15     5        INIT_FCALL                                               'sprintf'
          6        SEND_VAL                                                 'team%25d%3A+%25d%3B+'
          7        SEND_VAR                                                 !3
          8        COUNT                                            ~8      !2
          9        SEND_VAL                                                 ~8
         10        DO_ICALL                                         $9      
         11        ASSIGN_OP                                     8          !1, $9
   14    12      > JMP                                                      ->3
         13    >   FE_FREE                                                  $5
   17    14      > RETURN                                                   !1
   18    15*     > RETURN                                                   null

End of function counts

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.8 ms | 1398 KiB | 28 Q