3v4l.org

run code in 500+ PHP versions simultaneously
<?php function get_found_strings(string $haystack, array $needles): array { $regex = '/' . str_replace('\|', '|', preg_quote(implode('|', $needles))) . '/'; preg_match_all($regex, $haystack, $matches); return $matches[0]; } $string1 = "Example! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tortor ipsum, faucibus iaculis dapibus ut, mollis vel diam."; $array_to_find = [ "#Example", "Example!", "Example?" ]; var_dump(get_found_strings($string1, $array_to_find));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WtUVM
function name:  (null)
number of ops:  10
compiled vars:  !0 = $string1, !1 = $array_to_find
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, 'Example%21+Lorem+ipsum+dolor+sit+amet%2C+consectetur+adipiscing+elit.+Sed+tortor+ipsum%2C+faucibus+iaculis+dapibus+ut%2C+mollis+vel+diam.'
   13     1        ASSIGN                                                       !1, <array>
   19     2        INIT_FCALL                                                   'var_dump'
          3        INIT_FCALL                                                   'get_found_strings'
          4        SEND_VAR                                                     !0
          5        SEND_VAR                                                     !1
          6        DO_FCALL                                          0  $4      
          7        SEND_VAR                                                     $4
          8        DO_ICALL                                                     
          9      > RETURN                                                       1

Function get_found_strings:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WtUVM
function name:  get_found_strings
number of ops:  21
compiled vars:  !0 = $haystack, !1 = $needles, !2 = $regex, !3 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        INIT_FCALL                                                   'preg_quote'
          3        FRAMELESS_ICALL_2                implode             ~4      '%7C', !1
          4        SEND_VAL                                                     ~4
          5        DO_ICALL                                             $5      
          6        FRAMELESS_ICALL_3                str_replace         ~6      '%5C%7C', '%7C'
          7        OP_DATA                                                      $5
          8        CONCAT                                               ~7      '%2F', ~6
          9        CONCAT                                               ~8      ~7, '%2F'
         10        ASSIGN                                                       !2, ~8
    7    11        INIT_FCALL                                                   'preg_match_all'
         12        SEND_VAR                                                     !2
         13        SEND_VAR                                                     !0
         14        SEND_REF                                                     !3
         15        DO_ICALL                                                     
    8    16        FETCH_DIM_R                                          ~11     !3, 0
         17        VERIFY_RETURN_TYPE                                           ~11
         18      > RETURN                                                       ~11
    9    19*       VERIFY_RETURN_TYPE                                           
         20*     > RETURN                                                       null

End of function get_found_strings

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.13 ms | 1489 KiB | 17 Q