3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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
Jump found. Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
Jump found. Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
Jump found. Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
Jump found. Position 1 = -2
Branch analysis from position: 10
filename:       /in/QOINv
function name:  (null)
number of ops:  12
compiled vars:  !0 = $emails, !1 = $email
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  14     1        ASSIGN                                                   !0, <array>
  16     2      > FE_RESET_R                                       $3      !0, ->10
         3    > > FE_FETCH_R                                               $3, !1, ->10
  18     4    >   INIT_FCALL                                               'obfuscate_email'
         5        SEND_VAR                                                 !1
         6        DO_FCALL                                      0  $4      
         7        CONCAT                                           ~5      $4, '%0A'
         8        ECHO                                                     ~5
         9      > JMP                                                      ->3
        10    >   FE_FREE                                                  $3
        11      > RETURN                                                   1

Function obfuscate_email:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/QOINv
function name:  obfuscate_email
number of ops:  43
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        INIT_FCALL                                               'count'
        11        SEND_VAR                                                 !1
        12        DO_ICALL                                         $6      
        13        SUB                                              ~7      $6, 1
        14        SEND_VAL                                                 ~7
        15        DO_ICALL                                         $8      
        16        SEND_VAR                                                 $8
        17        SEND_VAL                                                 '%40'
        18        DO_ICALL                                         $9      
        19        ASSIGN                                                   !2, $9
   7    20        INIT_FCALL                                               'floor'
        21        STRLEN                                           ~11     !2
        22        DIV                                              ~12     ~11, 2
        23        SEND_VAL                                                 ~12
        24        DO_ICALL                                         $13     
        25        ASSIGN                                                   !3, $13
   9    26        INIT_FCALL                                               'substr'
        27        SEND_VAR                                                 !2
        28        SEND_VAL                                                 0
        29        SEND_VAR                                                 !3
        30        DO_ICALL                                         $15     
        31        INIT_FCALL                                               'str_repeat'
        32        SEND_VAL                                                 '%2A'
        33        SEND_VAR                                                 !3
        34        DO_ICALL                                         $16     
        35        CONCAT                                           ~17     $15, $16
        36        CONCAT                                           ~18     ~17, '%40'
        37        INIT_FCALL                                               'end'
        38        SEND_REF                                                 !1
        39        DO_ICALL                                         $19     
        40        CONCAT                                           ~20     ~18, $19
        41      > RETURN                                                   ~20
  11    42*     > RETURN                                                   null

End of function obfuscate_email

Generated using Vulcan Logic Dumper, using php 7.2.0