3v4l.org

run code in 500+ PHP versions simultaneously
<?php function truncateString($searchterm){ $string = 'Here is a sentence talking about blue. This sentence talks about red.'; $regex = '/.{0,10}\b' . $searchterm . '\b.{0,10}/si'; if (preg_match($regex, $string, $m)) { echo $m[0] . "\n"; } } truncateString('blue'); truncateString('red');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mJnSG
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                                   'truncatestring'
          1        SEND_VAL                                                     'blue'
          2        DO_FCALL                                          0          
   12     3        INIT_FCALL                                                   'truncatestring'
          4        SEND_VAL                                                     'red'
          5        DO_FCALL                                          0          
          6      > RETURN                                                       1

Function truncatestring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/mJnSG
function name:  truncateString
number of ops:  15
compiled vars:  !0 = $searchterm, !1 = $string, !2 = $regex, !3 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        ASSIGN                                                       !1, 'Here+is+a+sentence+talking+about+blue.++This+sentence+talks+about+red.'
    5     2        CONCAT                                               ~5      '%2F.%7B0%2C10%7D%5Cb', !0
          3        CONCAT                                               ~6      ~5, '%5Cb.%7B0%2C10%7D%2Fsi'
          4        ASSIGN                                                       !2, ~6
    6     5        INIT_FCALL                                                   'preg_match'
          6        SEND_VAR                                                     !2
          7        SEND_VAR                                                     !1
          8        SEND_REF                                                     !3
          9        DO_ICALL                                             $8      
         10      > JMPZ                                                         $8, ->14
    7    11    >   FETCH_DIM_R                                          ~9      !3, 0
         12        CONCAT                                               ~10     ~9, '%0A'
         13        ECHO                                                         ~10
    9    14    > > RETURN                                                       null

End of function truncatestring

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
180.7 ms | 2021 KiB | 16 Q