3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "Do you see that ? Indeed, I can see that, as well as this." ; //$starting_words_array = array('I '); $starting_words_array = array('Do','I '); $ending_words_array = array('?',','); //array ([0] => 'Do you see that ?' [1] => 'I can see that,') function SearchString($str, $starting_words_array, $ending_words_array ) { $res = []; forEach($starting_words_array as $test) { $pos = strpos($str, $test); if ($pos===false) continue; $found = []; forEach($ending_words_array as $test2) { $posStart = $pos+strlen($test); $pos2 = strpos($str, $test2, $posStart); $found[] = ($pos2!==false) ? $pos2 : INF; } $min = min($found); if ($min !== INF) $res[]= substr($str,$pos,$min-$pos) .$str[$min]; } return $res; } $ans = SearchString($str, $starting_words_array, $ending_words_array ); print_r($ans);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZU3Qc
function name:  (null)
number of ops:  13
compiled vars:  !0 = $str, !1 = $starting_words_array, !2 = $ending_words_array, !3 = $ans
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Do+you+see+that+%3F+Indeed%2C+I+can+see+that%2C+as+well+as+this.'
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
   27     3        INIT_FCALL                                               'searchstring'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !3, $7
   28     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function searchstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 52
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 52
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 34
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 34
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 51
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 51
Branch analysis from position: 34
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
filename:       /in/ZU3Qc
function name:  SearchString
number of ops:  55
compiled vars:  !0 = $str, !1 = $starting_words_array, !2 = $ending_words_array, !3 = $res, !4 = $test, !5 = $pos, !6 = $found, !7 = $test2, !8 = $posStart, !9 = $pos2, !10 = $min
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   10     3        ASSIGN                                                   !3, <array>
   11     4      > FE_RESET_R                                       $12     !1, ->52
          5    > > FE_FETCH_R                                               $12, !4, ->52
   12     6    >   INIT_FCALL                                               'strpos'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !4
          9        DO_ICALL                                         $13     
         10        ASSIGN                                                   !5, $13
   13    11        TYPE_CHECK                                    4          !5
         12      > JMPZ                                                     ~15, ->14
         13    > > JMP                                                      ->5
   14    14    >   ASSIGN                                                   !6, <array>
   15    15      > FE_RESET_R                                       $17     !2, ->34
         16    > > FE_FETCH_R                                               $17, !7, ->34
   16    17    >   STRLEN                                           ~18     !4
         18        ADD                                              ~19     !5, ~18
         19        ASSIGN                                                   !8, ~19
   17    20        INIT_FCALL                                               'strpos'
         21        SEND_VAR                                                 !0
         22        SEND_VAR                                                 !7
         23        SEND_VAR                                                 !8
         24        DO_ICALL                                         $21     
         25        ASSIGN                                                   !9, $21
   18    26        TYPE_CHECK                                  1018          !9
         27      > JMPZ                                                     ~24, ->30
         28    >   QM_ASSIGN                                        ~25     !9
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~25     INF
         31    >   ASSIGN_DIM                                               !6
         32        OP_DATA                                                  ~25
   15    33      > JMP                                                      ->16
         34    >   FE_FREE                                                  $17
   20    35        INIT_FCALL                                               'min'
         36        SEND_VAR                                                 !6
         37        DO_ICALL                                         $26     
         38        ASSIGN                                                   !10, $26
   21    39        IS_NOT_IDENTICAL                                         !10, INF
         40      > JMPZ                                                     ~28, ->51
   22    41    >   INIT_FCALL                                               'substr'
         42        SEND_VAR                                                 !0
         43        SEND_VAR                                                 !5
         44        SUB                                              ~30     !10, !5
         45        SEND_VAL                                                 ~30
         46        DO_ICALL                                         $31     
         47        FETCH_DIM_R                                      ~32     !0, !10
         48        CONCAT                                           ~33     $31, ~32
         49        ASSIGN_DIM                                               !3
         50        OP_DATA                                                  ~33
   11    51    > > JMP                                                      ->5
         52    >   FE_FREE                                                  $12
   24    53      > RETURN                                                   !3
   25    54*     > RETURN                                                   null

End of function searchstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.94 ms | 1021 KiB | 18 Q