3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "this is a long string"; $length = strlen($str); $dir = -1; $delta = $length; $maxlength = 12; while(intval($delta)){ $delta = $delta / 2; $length = $length + $dir * $delta; if($dir * (strlen(substr($str, 0, $length)) - $maxlength) > 0) $dir = -$dir; echo substr($str, 0, $length)." ". $delta. "\n"; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 7
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 7
Branch analysis from position: 35
Branch analysis from position: 7
Branch analysis from position: 24
filename:       /in/g1N2m
function name:  (null)
number of ops:  36
compiled vars:  !0 = $str, !1 = $length, !2 = $dir, !3 = $delta, !4 = $maxlength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'this+is+a+long+string'
    5     1        STRLEN                                           ~6      !0
          2        ASSIGN                                                   !1, ~6
    6     3        ASSIGN                                                   !2, -1
    7     4        ASSIGN                                                   !3, !1
    9     5        ASSIGN                                                   !4, 12
   11     6      > JMP                                                      ->33
   12     7    >   DIV                                              ~11     !3, 2
          8        ASSIGN                                                   !3, ~11
   13     9        MUL                                              ~13     !2, !3
         10        ADD                                              ~14     !1, ~13
         11        ASSIGN                                                   !1, ~14
   14    12        INIT_FCALL                                               'substr'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 0
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $16     
         17        STRLEN                                           ~17     $16
         18        SUB                                              ~18     ~17, !4
         19        MUL                                              ~19     !2, ~18
         20        IS_SMALLER                                               0, ~19
         21      > JMPZ                                                     ~20, ->24
         22    >   MUL                                              ~21     !2, -1
         23        ASSIGN                                                   !2, ~21
   15    24    >   INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 0
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $23     
         29        CONCAT                                           ~24     $23, '+++++++'
         30        CONCAT                                           ~25     ~24, !3
         31        CONCAT                                           ~26     ~25, '%0A'
         32        ECHO                                                     ~26
   11    33    >   CAST                                          4  ~27     !3
         34      > JMPNZ                                                    ~27, ->7
   17    35    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.5 ms | 1396 KiB | 15 Q