3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = "string with dot. And another. Again."; $n = 35; // in your case 100 $pos = strrpos(substr($str,0,$n), "."); If($pos === false) $pos = strlen($str); Echo substr($str,0, $pos+1);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/YS7X7
function name:  (null)
number of ops:  18
compiled vars:  !0 = $str, !1 = $n, !2 = $pos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'string+with+dot.+And+another.+Again.'
    5     1        ASSIGN                                                       !1, 35
    6     2        INIT_FCALL                                                   'strrpos'
          3        FRAMELESS_ICALL_3                substr              ~5      !0, 0
          4        OP_DATA                                                      !1
          5        SEND_VAL                                                     ~5
          6        SEND_VAL                                                     '.'
          7        DO_ICALL                                             $6      
          8        ASSIGN                                                       !2, $6
    7     9        TYPE_CHECK                                        4          !2
         10      > JMPZ                                                         ~8, ->13
         11    >   STRLEN                                               ~9      !0
         12        ASSIGN                                                       !2, ~9
    8    13    >   ADD                                                  ~11     !2, 1
         14        FRAMELESS_ICALL_3                substr              ~12     !0, 0
         15        OP_DATA                                                      ~11
         16        ECHO                                                         ~12
         17      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.66 ms | 2022 KiB | 14 Q