3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'I try both of previous answer (not working for me 😥). After downloading the last beta, not working too. After I changed the iOS Deployement target (11.1 -> 14.0) it\'s working Hope that can help someone 🙏🏽'; $bl = [ 'thank you', 'thanks', 'thankyou', 'best regards', 'regards', 'cheers', 'thx', 'thanx', 'appreciated', 'good afternoon', 'buenas tardes', 'hi there', 'good day', 'This is long 😊', 'good morning', 'hope that can help', 'help someone', ]; function regex(array $bl, string $string) { $m = []; foreach ($bl as $word) { preg_match_all('#'.$word.'#i', $string, $matches, PREG_SET_ORDER, 0); foreach ($matches as $e) { $m[] = $e[0]; } } } function str(array $bl, string $string) { $m = []; foreach ($bl as $word) { if (stripos($string, $word) !== false) { $m[] = $word; } } } // bench $time = microtime(true); $i = 10000; while ($i--) { str($bl, $str); } echo 'stripos: '.round(microtime(true) - $time, 3)."\n"; $time = microtime(true); $i = 10000; while ($i--) { regex($bl, $str); } echo 'Regex: '.round(microtime(true) - $time, 3)."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 8
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 31
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 31
Branch analysis from position: 37
Branch analysis from position: 31
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 8
Branch analysis from position: 14
Branch analysis from position: 8
filename:       /in/rnFlh
function name:  (null)
number of ops:  49
compiled vars:  !0 = $str, !1 = $bl, !2 = $time, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'I+try+both+of+previous+answer+%28not+working+for+me+%F0%9F%98%A5%29.%0AAfter+downloading+the+last+beta%2C+not+working+too.%0AAfter+I+changed+the+iOS+Deployement+target+%2811.1+-%3E+14.0%29+it%27s+working%0A%0AHope+that+can+help+someone+%F0%9F%99%8F%F0%9F%8F%BD'
    9     1        ASSIGN                                                   !1, <array>
   50     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !2, $6
   51     6        ASSIGN                                                   !3, 10000
   52     7      > JMP                                                      ->12
   53     8    >   INIT_FCALL                                               'str'
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0          
   52    12    >   POST_DEC                                         ~10     !3
         13      > JMPNZ                                                    ~10, ->8
   55    14    >   INIT_FCALL                                               'round'
         15        INIT_FCALL                                               'microtime'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $11     
         18        SUB                                              ~12     $11, !2
         19        SEND_VAL                                                 ~12
         20        SEND_VAL                                                 3
         21        DO_ICALL                                         $13     
         22        CONCAT                                           ~14     'stripos%3A+', $13
         23        CONCAT                                           ~15     ~14, '%0A'
         24        ECHO                                                     ~15
   57    25        INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $16     
         28        ASSIGN                                                   !2, $16
   58    29        ASSIGN                                                   !3, 10000
   59    30      > JMP                                                      ->35
   60    31    >   INIT_FCALL                                               'regex'
         32        SEND_VAR                                                 !1
         33        SEND_VAR                                                 !0
         34        DO_FCALL                                      0          
   59    35    >   POST_DEC                                         ~20     !3
         36      > JMPNZ                                                    ~20, ->31
   62    37    >   INIT_FCALL                                               'round'
         38        INIT_FCALL                                               'microtime'
         39        SEND_VAL                                                 <true>
         40        DO_ICALL                                         $21     
         41        SUB                                              ~22     $21, !2
         42        SEND_VAL                                                 ~22
         43        SEND_VAL                                                 3
         44        DO_ICALL                                         $23     
         45        CONCAT                                           ~24     'Regex%3A+', $23
         46        CONCAT                                           ~25     ~24, '%0A'
         47        ECHO                                                     ~25
         48      > RETURN                                                   1

Function regex:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/rnFlh
function name:  regex
number of ops:  24
compiled vars:  !0 = $bl, !1 = $string, !2 = $m, !3 = $word, !4 = $matches, !5 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   30     2        ASSIGN                                                   !2, <array>
   31     3      > FE_RESET_R                                       $7      !0, ->22
          4    > > FE_FETCH_R                                               $7, !3, ->22
   32     5    >   INIT_FCALL                                               'preg_match_all'
          6        CONCAT                                           ~8      '%23', !3
          7        CONCAT                                           ~9      ~8, '%23i'
          8        SEND_VAL                                                 ~9
          9        SEND_VAR                                                 !1
         10        SEND_REF                                                 !4
         11        SEND_VAL                                                 2
         12        SEND_VAL                                                 0
         13        DO_ICALL                                                 
   33    14      > FE_RESET_R                                       $11     !4, ->20
         15    > > FE_FETCH_R                                               $11, !5, ->20
   34    16    >   FETCH_DIM_R                                      ~13     !5, 0
         17        ASSIGN_DIM                                               !2
         18        OP_DATA                                                  ~13
   33    19      > JMP                                                      ->15
         20    >   FE_FREE                                                  $11
   31    21      > JMP                                                      ->4
         22    >   FE_FREE                                                  $7
   37    23      > RETURN                                                   null

End of function regex

Function str:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/rnFlh
function name:  str
number of ops:  16
compiled vars:  !0 = $bl, !1 = $string, !2 = $m, !3 = $word
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   40     2        ASSIGN                                                   !2, <array>
   41     3      > FE_RESET_R                                       $5      !0, ->14
          4    > > FE_FETCH_R                                               $5, !3, ->14
   42     5    >   INIT_FCALL                                               'stripos'
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $6      
          9        TYPE_CHECK                                  1018          $6
         10      > JMPZ                                                     ~7, ->13
   43    11    >   ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !3
   41    13    > > JMP                                                      ->4
         14    >   FE_FREE                                                  $5
   46    15      > RETURN                                                   null

End of function str

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.46 ms | 1411 KiB | 23 Q