3v4l.org

run code in 500+ PHP versions simultaneously
<?php $re = '/(?<!\S)(?:(?!keyword\b)\w+\h+){1,3}keyword\b(?=((?:\h+(?!keyword\b)\w+){1,3}))/u'; $strings = [ "word1 word2 word3 keyword word4 word5 word6 keyword word7 word8 word9 word10", "word2 keyword word4 word5 word6 keyword word7 word8", "word2 word3 keyword word4 word5 word6 keyword word7 keyword word10", ]; foreach ($strings as $str) { preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); $matches = array_map(function($m) { return $m[0] . $m[1]; }, $matches); print_r($matches); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/aa2oL
function name:  (null)
number of ops:  23
compiled vars:  !0 = $re, !1 = $strings, !2 = $str, !3 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%2F%28%3F%3C%21%5CS%29%28%3F%3A%28%3F%21keyword%5Cb%29%5Cw%2B%5Ch%2B%29%7B1%2C3%7Dkeyword%5Cb%28%3F%3D%28%28%3F%3A%5Ch%2B%28%3F%21keyword%5Cb%29%5Cw%2B%29%7B1%2C3%7D%29%29%2Fu'
    5     1        ASSIGN                                                       !1, <array>
   11     2      > FE_RESET_R                                           $6      !1, ->21
          3    > > FE_FETCH_R                                                   $6, !2, ->21
   12     4    >   INIT_FCALL                                                   'preg_match_all'
          5        SEND_VAR                                                     !0
          6        SEND_VAR                                                     !2
          7        SEND_REF                                                     !3
          8        SEND_VAL                                                     2
          9        SEND_VAL                                                     0
         10        DO_ICALL                                                     
   13    11        INIT_FCALL                                                   'array_map'
         12        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
   15    13        SEND_VAL                                                     ~8
         14        SEND_VAR                                                     !3
   13    15        DO_ICALL                                             $9      
         16        ASSIGN                                                       !3, $9
   16    17        INIT_FCALL                                                   'print_r'
         18        SEND_VAR                                                     !3
         19        DO_ICALL                                                     
   11    20      > JMP                                                          ->3
         21    >   FE_FREE                                                      $6
   17    22      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aa2oL
function name:  {closure:/in/aa2oL:13}
number of ops:  6
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   14     1        FETCH_DIM_R                                          ~1      !0, 0
          2        FETCH_DIM_R                                          ~2      !0, 1
          3        CONCAT                                               ~3      ~1, ~2
          4      > RETURN                                                       ~3
   15     5*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.14 ms | 2060 KiB | 16 Q