3v4l.org

run code in 500+ 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 = 26
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/CKFbt
function name:  (null)
number of ops:  28
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, ->26
          8    > > FE_FETCH_R                                           ~14     $13, !4, ->26
          9    >   ASSIGN                                                       !5, ~14
    9    10        INIT_FCALL                                                   'printf'
   10    11        SEND_VAL                                                     '%25d%3A+%25s%0A'
   11    12        SEND_VAR                                                     !5
   14    13        INIT_FCALL                                                   'array_slice'
   15    14        SEND_VAR                                                     !0
   16    15        SUB                                                  ~16     !1, !2
         16        SUB                                                  ~17     !5, !3
         17        FRAMELESS_ICALL_2                max                 ~18     0, ~17
         18        FRAMELESS_ICALL_2                min                 ~19     ~16, ~18
         19        SEND_VAL                                                     ~19
   17    20        SEND_VAR                                                     !2
   14    21        DO_ICALL                                             $20     
   12    22        FRAMELESS_ICALL_2                implode             ~21     '%2C', $20
   17    23        SEND_VAL                                                     ~21
    9    24        DO_ICALL                                                     
    8    25      > JMP                                                          ->8
         26    >   FE_FREE                                                      $13
   21    27      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.58 ms | 1884 KiB | 15 Q