Page 1 of 1

Displaying email addresses

Posted: Wed Sep 05, 2007 3:28 am
by kkonline
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


is there any function or class that converts you@yourdomain.com into
you [at] yourdomain [dot] com when an actual email is passed to the class/function?

I wrote

Code: Select all

<?php


//initialize spam-off function (embed it inna page) - JavaScript
function mailto($address,$text='',$subject=''){
$address="user@mail.com";
#divide user from host (cut on @)
$data = explode("@","$address");
#a little extra make-up 
$hostitj = ereg_replace("\.", ' <u>[dot]</u> ', $data[1]);
#if no text present, display address, just a little formatted 
if ("$text" == "") { $text = $data[0] . ' <u>[at]</u> ' . $hostitj; }
#write link
echo "<a href=\"" . $data[1] . "','" . $data[0] . "'\">" . $text . "</a>";

}
?>
But it gives no error and no display on the screen


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Sep 05, 2007 6:25 am
by onion2k
A function, no. You can do it pretty easily with str_replace though.

Code: Select all

$emailAddress = "onion@domain.com";
$emailAddressProtected = str_replace(array(".","@"), array(" [dot] "," [at] "), $emailAddress);

Posted: Wed Sep 05, 2007 9:39 am
by xpgeek
Another thread this some question is here: viewtopic.php?t=73381&highlight=
This question asks very often - try search before creating new thread please.