/**
* Obfuscate an email address
*
* @author Aidan Lister
* @version 1.1.0
* @link http://aidanlister.com/2004/04/quick-javascript-email-obfuscation/
* @param string $email E-mail
* @param string $text Text
*/
function mail_obfuscate($email, $text = '')
{
// Default text
if (empty($text)) {
$text = $email;
}
// Create string
$string = sprintf('document.write('%s');',
htmlspecialchars($email),
htmlspecialchars($text));
// Encode
for ($encode = '', $i = 0; $i < strlen($string); $i++) {
$encode .= '%' . bin2hex($string[$i]);
}
// Javascript
$javascript = '';
return $javascript;
}