Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP string replace help
Old 05-25-2005, 02:24 AM PHP string replace help
jim1228's Avatar
Extreme Talker

Posts: 195
Name: Jim
Location: Ohio
Trades: 0
I need a function to find an email in a string and then replace it with *****

Hide emails in a string

Thanks in advance if you got something laying around
jim1228 is offline
Reply With Quote
View Public Profile Visit jim1228's homepage!
 
 
Register now for full access!
Old 05-25-2005, 02:43 AM
jim1228's Avatar
Extreme Talker

Posts: 195
Name: Jim
Location: Ohio
Trades: 0
What I got so far:

what could I use to match for emails?

Code:
$search = "@";

$replace = "**No Emails Allowed!**";

$pos = strpos($about, $search);

if (is_int($pos)) {
$len = strlen($search);
$about = substr_replace($about, $replace, $pos, $len);
}
jim1228 is offline
Reply With Quote
View Public Profile Visit jim1228's homepage!
 
Old 05-25-2005, 06:59 AM
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
PHP Code:
<?

$string 
"email@email.com\n \n email@email.com \n email@email.com";
echo 
"$string\n";
$string preg_replace("![^\s@]+@[\S]+!s""*****"$string);
echo 
"$string\n";

?>
Output:
Code:
email@email.com
 
 email@email.com 
 email@email.com
*****
 
 ***** 
 *****
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to PHP string replace help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11298 seconds with 12 queries