3v4l.org

run code in 500+ PHP versions simultaneously
<?php $alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $offset = 1; $limit = 6; $start = max(0, $offset-$limit); $end = min(strlen($alpha)-1, $offset+$limit); Echo substr($alpha, $start, $end-$start+1); /* To output them one by one as in an array you can use this: $result = substr($alpha, $start, $end-$start+1); For($i=0; $i<strlen($result); $i++){ Echo $result[$i] . "\n"; } Or you can explode("", $result); to make it a true array */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sfCKY
function name:  (null)
number of ops:  17
compiled vars:  !0 = $alpha, !1 = $offset, !2 = $limit, !3 = $start, !4 = $end
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    4     1        ASSIGN                                                       !1, 1
    5     2        ASSIGN                                                       !2, 6
    7     3        SUB                                                  ~8      !1, !2
          4        FRAMELESS_ICALL_2                max                 ~9      0, ~8
          5        ASSIGN                                                       !3, ~9
    8     6        STRLEN                                               ~11     !0
          7        SUB                                                  ~12     ~11, 1
          8        ADD                                                  ~13     !1, !2
          9        FRAMELESS_ICALL_2                min                 ~14     ~12, ~13
         10        ASSIGN                                                       !4, ~14
   10    11        SUB                                                  ~16     !4, !3
         12        ADD                                                  ~17     ~16, 1
         13        FRAMELESS_ICALL_3                substr              ~18     !0, !3
         14        OP_DATA                                                      ~17
         15        ECHO                                                         ~18
   22    16      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.98 ms | 2566 KiB | 13 Q