3v4l.org

run code in 300+ PHP versions simultaneously
<?php function splitEmail($str) { $pattern = "/([\w\s\'\"]+[\s]+)?(<)?(([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4}))?(>)?/g"; preg_match($pattern, $str, $match); return array( 'name' => isset($match[1]) ? trim($match[1]) : null, 'email' => isset($match[3]) ? trim($match[3]) : null, ); } $e = array( '<foo@bar.com>', 'Miguel <miguel@bar.com>', '"ddd" <123@d.com>', 'll\'f <ddd@ddd.ll>', 'foo@bar.com', ); foreach($e as $v) { var_dump(splitEmail($v)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/itu9L
function name:  (null)
number of ops:  12
compiled vars:  !0 = $e, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   21     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                               $3, !1, ->10
   22     3    >   INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'splitemail'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   21     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   23    11      > RETURN                                                   1

Function splitemail:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
Branch analysis from position: 25
filename:       /in/itu9L
function name:  splitEmail
number of ops:  29
compiled vars:  !0 = $str, !1 = $pattern, !2 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, '%2F%28%5B%5Cw%5Cs%5C%27%22%5D%2B%5B%5Cs%5D%2B%29%3F%28%3C%29%3F%28%28%5B%5Cw-%5C.%5D%2B%29%40%28%28%3F%3A%5B%5Cw%5D%2B%5C.%29%2B%29%28%5Ba-zA-Z%5D%7B2%2C4%7D%29%29%3F%28%3E%29%3F%2Fg'
    6     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    8     7        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 1
          8      > JMPZ                                                     ~5, ->15
          9    >   INIT_FCALL                                               'trim'
         10        FETCH_DIM_R                                      ~6      !2, 1
         11        SEND_VAL                                                 ~6
         12        DO_ICALL                                         $7      
         13        QM_ASSIGN                                        ~8      $7
         14      > JMP                                                      ->16
         15    >   QM_ASSIGN                                        ~8      null
         16    >   INIT_ARRAY                                       ~9      ~8, 'name'
    9    17        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 3
         18      > JMPZ                                                     ~10, ->25
         19    >   INIT_FCALL                                               'trim'
         20        FETCH_DIM_R                                      ~11     !2, 3
         21        SEND_VAL                                                 ~11
         22        DO_ICALL                                         $12     
         23        QM_ASSIGN                                        ~13     $12
         24      > JMP                                                      ->26
    8    25    >   QM_ASSIGN                                        ~13     null
         26    >   ADD_ARRAY_ELEMENT                                ~9      ~13, 'email'
         27      > RETURN                                                   ~9
   11    28*     > RETURN                                                   null

End of function splitemail

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.16 ms | 1403 KiB | 20 Q