Skip to content

Instantly share code, notes, and snippets.

@bboxwechat
Created June 9, 2019 06:55
Show Gist options
  • Save bboxwechat/4d7279d8b754fb4388be2a65a7fa3b57 to your computer and use it in GitHub Desktop.
Save bboxwechat/4d7279d8b754fb4388be2a65a7fa3b57 to your computer and use it in GitHub Desktop.
<?php function encode_email($email = '[email protected]', $linkText = 'Contact Us', $attrs = 'class="emailencoder"') {     // remplazar aroba y puntos     $email = str_replace('@', '@', $email);     $email = str_replace('.', '.', $email);     $email = str_split($email, 5);       $linkText = str_replace('@', '@', $linkText);     $linkText = str_replace('.', '.', $linkText);     $linkText = str_split($linkText, 5);       $part1 = '<a href="ma';     $part2 = 'ilto:';     $part3 = '" '. $attrs .' >';     $part4 = '</a>';       $encoded = '<script type="text/javascript">';     $encoded .= "document.write('$part1');";     $encoded .= "document.write('$part2');";     foreach ($email as $e) {         $encoded .= "document.write('$e');";     }     $encoded .= "document.write('$part3');";     foreach ($linkText as $l) {         $encoded .= "document.write('$l');";     }     $encoded .= "document.write('$part4');";     $encoded .= '</script>';       return $encoded; } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment