3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ 17 => 'absv shss xcnx shss hshhs shhsw shshs hsnna hssnnss hssns snnss nnshs sjjjjsjsj nsnnnsns jjsnss snsnns nsnns', 8 => 'absv shss xcnx shss hshhs shhsw shshs hsnna', 5 => 'absv shss xcnx shss hshhs' ]; $wordLimit = 8; foreach ($strings as $string) { echo preg_replace('/(?:\s*\S++){' . $wordLimit . '}\K.+/', '...', $string); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/vJuo6
function name:  (null)
number of ops:  16
compiled vars:  !0 = $strings, !1 = $wordLimit, !2 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 8
   11     2      > FE_RESET_R                                       $5      !0, ->14
          3    > > FE_FETCH_R                                               $5, !2, ->14
   12     4    >   INIT_FCALL                                               'preg_replace'
          5        CONCAT                                           ~6      '%2F%28%3F%3A%5Cs%2A%5CS%2B%2B%29%7B', !1
          6        CONCAT                                           ~7      ~6, '%7D%5CK.%2B%2F'
          7        SEND_VAL                                                 ~7
          8        SEND_VAL                                                 '...'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $8      
         11        ECHO                                                     $8
   13    12        ECHO                                                     '%0A---%0A'
   11    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $5
   14    15      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.06 ms | 1010 KiB | 14 Q