3v4l.org

run code in 300+ 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 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/YS7X7
function name:  (null)
number of ops:  24
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        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8        SEND_VAR                                                 $5
          9        SEND_VAL                                                 '.'
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !2, $6
    7    12        TYPE_CHECK                                    4          !2
         13      > JMPZ                                                     ~8, ->16
         14    >   STRLEN                                           ~9      !0
         15        ASSIGN                                                   !2, ~9
    8    16    >   INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 0
         19        ADD                                              ~11     !2, 1
         20        SEND_VAL                                                 ~11
         21        DO_ICALL                                         $12     
         22        ECHO                                                     $12
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.31 ms | 1002 KiB | 15 Q