3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [0, 1, 2, 3, 4, 5, 6, 7]; $count = count($a); $span = 5; // most sensible with odd numbers $center = (int)($span / 2); foreach ($a as $i => $v) { printf( "%d: %s\n", $i, implode( ',', array_slice( $a, min($count - $span, max(0, $i - $center)), $span ) ) ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 35
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 35
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/CKFbt
function name:  (null)
number of ops:  37
compiled vars:  !0 = $a, !1 = $count, !2 = $span, !3 = $center, !4 = $v, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        COUNT                                            ~7      !0
          2        ASSIGN                                                   !1, ~7
    5     3        ASSIGN                                                   !2, 5
    6     4        DIV                                              ~10     !2, 2
          5        CAST                                          4  ~11     ~10
          6        ASSIGN                                                   !3, ~11
    8     7      > FE_RESET_R                                       $13     !0, ->35
          8    > > FE_FETCH_R                                       ~14     $13, !4, ->35
          9    >   ASSIGN                                                   !5, ~14
    9    10        INIT_FCALL                                               'printf'
   10    11        SEND_VAL                                                 '%25d%3A+%25s%0A'
   11    12        SEND_VAR                                                 !5
   12    13        INIT_FCALL                                               'implode'
   13    14        SEND_VAL                                                 '%2C'
   14    15        INIT_FCALL                                               'array_slice'
   15    16        SEND_VAR                                                 !0
   16    17        INIT_FCALL                                               'min'
         18        SUB                                              ~16     !1, !2
         19        SEND_VAL                                                 ~16
         20        INIT_FCALL                                               'max'
         21        SEND_VAL                                                 0
         22        SUB                                              ~17     !5, !3
         23        SEND_VAL                                                 ~17
         24        DO_ICALL                                         $18     
         25        SEND_VAR                                                 $18
         26        DO_ICALL                                         $19     
         27        SEND_VAR                                                 $19
   17    28        SEND_VAR                                                 !2
   14    29        DO_ICALL                                         $20     
   17    30        SEND_VAR                                                 $20
   12    31        DO_ICALL                                         $21     
   17    32        SEND_VAR                                                 $21
    9    33        DO_ICALL                                                 
    8    34      > JMP                                                      ->8
         35    >   FE_FREE                                                  $13
   21    36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.73 ms | 1003 KiB | 18 Q