remove all email address and links from post a string in php


I was looking to remove all email address and links from post

for a non-commercial posting website (like forum or classifieds)

The function

<?PHP
function verify_email_and_link_in_post($c){
# modify email addess and link with this:
$l=”LINKS ARE PROHIBITED ON THIS WEBSITE”;
$e=”EMAIL ADDRESS ARE PROHIBITER ON THIS WEBSITE”;
# check for email address
$c=ereg_replace(“[-a-z0-9!#$%&\’*+/=?^_`{|}~]+@([.]?[a-zA-Z0-9_/-])*”,$e,$c);
# replace all sign @ with the letters at
$c=ereg_replace(“@”, ” at “,$c);
# check for link HTML input
$c=eregi_replace(‘(<a [^<]*href=[“|\’]?([^ “\’]*)[“|\’]?[^>].*>([^<]*)</a>)’,$l,$c);
# check for anythink like http:// or ftp://
$c=ereg_replace(“[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*”,$l,$c);
# check for anyhting starting with www.
$c=ereg_replace(“(^| )(www([-]*[.]?[a-zA-Z0-9_/-?&%])*)”,$l,$c);
# finaly check for anything like a-z.a-z
$c=ereg_replace(“[-a-z0-9!#$%&\’*+/=?^_`{|}~]+[.]+[-a-z0-9]”,$l,$c);
return $c;
}
?>

hope this help someone;-)

Advertisements
By karuppasamy11486 Posted in php

2 comments on “remove all email address and links from post a string in php

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s