3v4l.org

run code in 300+ PHP versions simultaneously
<?php function obfuscate_email($email) { $em = explode("@",$email); $name = implode(array_slice($em, 0, count($em)-1), '@'); $len = floor(strlen($name)/2); return substr($name,0, $len) . str_repeat('*', $len) . "@" . end($em); } // to see in action: $emails = ['"Abc\@def"@iana.org', 'abcdlkjlkjk@hotmail.com', 'cal(foo\@bar)@iamcal.com']; foreach ($emails as $email) { echo obfuscate_email($email) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/QOINv
function name:  (null)
number of ops:  11
compiled vars:  !0 = $emails, !1 = $email
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   16     1      > FE_RESET_R                                       $3      !0, ->9
          2    > > FE_FETCH_R                                               $3, !1, ->9
   18     3    >   INIT_FCALL                                               'obfuscate_email'
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      $4, '%0A'
          7        ECHO                                                     ~5
   16     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $3
   19    10      > RETURN                                                   1

Function obfuscate_email:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QOINv
function name:  obfuscate_email
number of ops:  41
compiled vars:  !0 = $email, !1 = $em, !2 = $name, !3 = $len
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%40'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
    6     6        INIT_FCALL                                               'implode'
          7        INIT_FCALL                                               'array_slice'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 0
         10        COUNT                                            ~6      !1
         11        SUB                                              ~7      ~6, 1
         12        SEND_VAL                                                 ~7
         13        DO_ICALL                                         $8      
         14        SEND_VAR                                                 $8
         15        SEND_VAL                                                 '%40'
         16        DO_ICALL                                         $9      
         17        ASSIGN                                                   !2, $9
    7    18        INIT_FCALL                                               'floor'
         19        STRLEN                                           ~11     !2
         20        DIV                                              ~12     ~11, 2
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                         $13     
         23        ASSIGN                                                   !3, $13
    9    24        INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !2
         26        SEND_VAL                                                 0
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                         $15     
         29        INIT_FCALL                                               'str_repeat'
         30        SEND_VAL                                                 '%2A'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                         $16     
         33        CONCAT                                           ~17     $15, $16
         34        CONCAT                                           ~18     ~17, '%40'
         35        INIT_FCALL                                               'end'
         36        SEND_REF                                                 !1
         37        DO_ICALL                                         $19     
         38        CONCAT                                           ~20     ~18, $19
         39      > RETURN                                                   ~20
   11    40*     > RETURN                                                   null

End of function obfuscate_email

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.9 ms | 1403 KiB | 28 Q