3v4l.org

run code in 300+ PHP versions simultaneously
<?php $extractor = function ($str) { $str = preg_replace('/\s*(?:\[at]|@)\s*/', '@', $str); $str = preg_replace('/\s*\(dot\)\s*/', '.', $str); $regexp = '/\b[a-z0-9_.-]+@(?:[a-z0-9-]+\.)+[a-z0-9]{2,4}\b/i'; preg_match_all($regexp, $str, $m); return isset($m[0]) ? $m[0] : []; }; $test_string = 'This is a test string... test1@example.org Test different formats: test2@example.org; <a href="test3@example.org">foobar</a> <test4@example.org> strange formats: test5@example.org test6[at]example.org test7@example.net.org.com test8@ example.org test9@!foo!.org test10.abc [at] hello (dot) com foobar '; print_r( $extractor($test_string) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KZgKY
function name:  (null)
number of ops:  10
compiled vars:  !0 = $extractor, !1 = $test_string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          1        ASSIGN                                                   !0, ~2
   11     2        ASSIGN                                                   !1, 'This+is+a+test+string...%0A++++test1%40example.org%0A++++Test+different+formats%3A%0A++++test2%40example.org%3B%0A++++%3Ca+href%3D%22test3%40example.org%22%3Efoobar%3C%2Fa%3E%0A++++%3Ctest4%40example.org%3E%0A++++++++strange+formats%3A%0A++++test5%40example.org%0A++++test6%5Bat%5Dexample.org%0A++++test7%40example.net.org.com%0A++++test8%40+example.org%0A++++test9%40%21foo%21.org%0A++++test10.abc+%5Bat%5D+hello+%28dot%29+com%0A++++++++foobar%0A'
   27     3        INIT_FCALL                                               'print_r'
          4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $5      
          7        SEND_VAR                                                 $5
          8        DO_ICALL                                                 
          9      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KZgKY
function name:  {closure}
number of ops:  27
compiled vars:  !0 = $str, !1 = $regexp, !2 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5Cs%2A%28%3F%3A%5C%5Bat%5D%7C%40%29%5Cs%2A%2F'
          3        SEND_VAL                                                 '%40'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    5     7        INIT_FCALL                                               'preg_replace'
          8        SEND_VAL                                                 '%2F%5Cs%2A%5C%28dot%5C%29%5Cs%2A%2F'
          9        SEND_VAL                                                 '.'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
    6    13        ASSIGN                                                   !1, '%2F%5Cb%5Ba-z0-9_.-%5D%2B%40%28%3F%3A%5Ba-z0-9-%5D%2B%5C.%29%2B%5Ba-z0-9%5D%7B2%2C4%7D%5Cb%2Fi'
    7    14        INIT_FCALL                                               'preg_match_all'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !0
         17        SEND_REF                                                 !2
         18        DO_ICALL                                                 
    8    19        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 0
         20      > JMPZ                                                     ~9, ->24
         21    >   FETCH_DIM_R                                      ~10     !2, 0
         22        QM_ASSIGN                                        ~11     ~10
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~11     <array>
         25    > > RETURN                                                   ~11
    9    26*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
275.63 ms | 1017 KiB | 16 Q